/* ============ isa-crm UI — лёгкая минималистичная дизайн-система ============ */
/* Темы: html[data-theme="light"|"dark"], выставляется скриптом в <head> до отрисовки */

:root, html[data-theme="light"] {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --hover: #fafbfc;
  --panel-foot: #fafbfc;
  --text: #1b1e23;
  --muted: #6b7280;
  --line: #e7e9ee;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-line: #d7dbfd;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-line: #fecaca;
  --ok: #16a34a;
  --dot-off: #cbd0d8;
  --placeholder: #9aa1ab;
  --toast-bg: #1b1e23;
  --toast-text: #ffffff;
  --stage-text: #ffffff;
  --top-bg: rgba(245, 246, 248, .85);
  --auth-glow-1: #e4e7ff;
  --auth-glow-2: #e9f4ff;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-2: 0 8px 24px rgba(16, 24, 40, .10);
  /* Цвета типов файлов (Диск) */
  --ft-red: #dc2626;    --ft-red-soft: rgba(220, 38, 38, .09);
  --ft-green: #15803d;  --ft-green-soft: rgba(22, 163, 74, .10);
  --ft-blue: #2563eb;   --ft-blue-soft: rgba(37, 99, 235, .09);
  --ft-violet: #7c3aed; --ft-violet-soft: rgba(124, 58, 237, .09);
  --ft-amber: #b45309;  --ft-amber-soft: rgba(217, 119, 6, .10);
}

html[data-theme="dark"] {
  --bg: #101216;
  --surface: #181b21;
  --hover: #1d2129;
  --panel-foot: #14171c;
  --text: #e7e9ee;
  --muted: #8b93a1;
  --line: #262b34;
  --accent: #818cf8;
  --accent-hover: #a5b0fc;
  --accent-soft: rgba(99, 102, 241, .16);
  --accent-line: rgba(129, 140, 248, .38);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --danger-line: rgba(248, 113, 113, .35);
  --ok: #34d399;
  --dot-off: #4b5563;
  --placeholder: #667082;
  --toast-bg: #e7e9ee;
  --toast-text: #14171c;
  --stage-text: #101216;
  --top-bg: rgba(16, 18, 22, .82);
  --auth-glow-1: rgba(79, 70, 229, .22);
  --auth-glow-2: rgba(37, 99, 235, .14);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .35), 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-2: 0 8px 24px rgba(0, 0, 0, .45);
  --ft-red: #f87171;    --ft-red-soft: rgba(248, 113, 113, .13);
  --ft-green: #34d399;  --ft-green-soft: rgba(52, 211, 153, .13);
  --ft-blue: #60a5fa;   --ft-blue-soft: rgba(96, 165, 250, .13);
  --ft-violet: #a78bfa; --ft-violet-soft: rgba(167, 139, 250, .13);
  --ft-amber: #fbbf24;  --ft-amber-soft: rgba(251, 191, 36, .12);
}

:root {
  --radius: 12px;
  --radius-s: 8px;
  --speed: .18s;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background .25s, color .25s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; margin: 0 0 4px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.inline { display: inline; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }

.side {
  width: 232px;
  flex: 0 0 232px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow-1);
}
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -.01em; color: var(--text); }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  color: var(--text);
  position: relative;
  transition: background var(--speed), color var(--speed);
}
.nav-link svg { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); transition: color var(--speed); }
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
.nav-link.active svg { color: var(--accent); }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 20%; bottom: 20%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-link.disabled { color: var(--muted); cursor: default; }
.nav-link.disabled:hover { background: none; }
.nav-badge {
  margin-left: auto;
  font-size: 10.5px; font-weight: 600; text-transform: lowercase;
  padding: 1px 7px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; }
.nav-divider { height: 1px; background: var(--line); margin: 8px 4px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 24px;
  background: var(--top-bg);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top-title { font-weight: 600; }
.top-spacer { flex: 1; }

.burger {
  display: none;
  border: 0; background: none; padding: 6px; cursor: pointer;
  border-radius: var(--radius-s); color: var(--text);
}
.burger:hover { background: var(--surface); }
.burger svg { width: 20px; height: 20px; display: block; }

.theme-btn {
  border: 0; background: none; cursor: pointer;
  padding: 7px; border-radius: 10px; color: var(--muted);
  transition: background var(--speed), color var(--speed), transform var(--speed);
}
.theme-btn:hover { background: var(--surface); color: var(--text); }
.theme-btn:active { transform: scale(.92); }
.theme-btn svg { width: 18px; height: 18px; display: block; }
html[data-theme="light"] .theme-btn svg[data-th="light"] { display: none; }
html[data-theme="dark"] .theme-btn svg[data-th="dark"] { display: none; }

/* Меню пользователя */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 9px;
  border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--text);
  padding: 5px 8px; border-radius: 10px;
  transition: background var(--speed);
}
.user-btn:hover { background: var(--surface); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; font-weight: 650;
}
.user-drop {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--speed), transform var(--speed);
}
.user-menu.open .user-drop { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.user-drop-name { padding: 8px 10px 2px; font-weight: 600; }
.user-drop-sub { padding: 0 10px 8px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.drop-item {
  display: block; width: 100%; text-align: left;
  border: 0; background: none; cursor: pointer; font: inherit;
  padding: 8px 10px; border-radius: var(--radius-s); color: var(--text);
  transition: background var(--speed);
}
.drop-item:hover { background: var(--bg); }
.drop-item.danger { color: var(--danger); }
.drop-item.danger:hover { background: var(--danger-soft); }

.content { padding: 24px; max-width: 1600px; width: 100%; animation: fadeUp .3s ease; }

/* ---------- Карточки модулей ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 200px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--muted); margin: 26px 0 12px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-1);
  animation: fadeUp .35s ease backwards;
  color: var(--text);
  display: block;
}
.grid .card:nth-child(1) { animation-delay: .02s; }
.grid .card:nth-child(2) { animation-delay: .06s; }
.grid .card:nth-child(3) { animation-delay: .10s; }
.grid .card:nth-child(4) { animation-delay: .14s; }
.grid .card:nth-child(5) { animation-delay: .18s; }
.grid .card:nth-child(6) { animation-delay: .22s; }
.card-link { transition: transform var(--speed), box-shadow var(--speed), border-color var(--speed); }
.card-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: var(--accent-line);
  color: var(--text);
}
.card-off { background: var(--panel-foot); box-shadow: none; }
.card-off .card-icon { background: var(--bg); color: var(--muted); }
.card-icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
  margin-bottom: 12px;
}
.card-icon svg { width: 20px; height: 20px; }
.card-title { font-weight: 600; margin-bottom: 2px; }
.card-desc { font-size: 13px; color: var(--muted); }

/* ---------- Панели, таблицы ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  animation: fadeUp .3s ease;
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; font-weight: 550; color: var(--muted);
  padding: 11px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap; font-size: 13px;
}
table.list td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr { transition: background var(--speed); }
table.list tbody tr:hover { background: var(--hover); }
.cell-main { font-weight: 550; }
.cell-sub { font-size: 13px; color: var(--muted); }

.row-name { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-weight: 500; }
.row-name:hover { color: var(--accent); }
.row-icon { display: inline-grid; place-items: center; color: var(--muted); }
.row-icon svg { width: 17px; height: 17px; }
.row-icon.folder-ic { color: var(--accent); }

.chip {
  display: inline-block;
  padding: 2px 9px; margin: 1px 3px 1px 0;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 12.5px; color: var(--text);
  white-space: nowrap;
}
.chip.violet { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--dot-off); }

/* ---------- Выпадающее меню (кнопка-иконка) ---------- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 150px; z-index: 25;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px); pointer-events: none;
  transition: opacity var(--speed), transform var(--speed);
}
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }

/* ---------- Диск: панель фильтров, сортировка, сетка ---------- */
.disk-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-select {
  width: auto;
  padding: 7px 12px;
  font-size: 13.5px;
  border-radius: 9px;
  cursor: pointer;
}
.view-toggle { display: flex; gap: 4px; margin-left: auto; }
.view-toggle .btn { padding: 6px 9px; min-height: 0; }
.view-toggle .btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}

th.sortable { cursor: pointer; user-select: none; transition: color var(--speed); }
th.sortable:hover { color: var(--text); }
th.sortable.sorted-asc::after { content: " ↑"; color: var(--accent); }
th.sortable.sorted-desc::after { content: " ↓"; color: var(--accent); }

.file-card { padding: 12px; }
.file-card-main { display: block; color: var(--text); }
.file-card-main:hover { color: var(--text); }
.file-card-main:hover .file-card-name { color: var(--accent); }
.file-card-icon {
  height: 96px;
  display: grid; place-items: center;
  background: var(--bg);
  border-radius: var(--radius-s);
  color: var(--muted);
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.file-card-icon .thumb {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.file-card-icon svg { width: 30px; height: 30px; }
.file-card-icon.folder-ic { background: var(--accent-soft); color: var(--accent); }

/* Палитры типов файлов: pdf — красный, таблицы — зелёный, документы — синий,
   изображения — янтарный, видео — фиолетовый */
.row-icon.k-pdf, .file-card-icon.k-pdf { color: var(--ft-red); }
.file-card-icon.k-pdf { background: var(--ft-red-soft); }
.row-icon.k-sheet, .file-card-icon.k-sheet { color: var(--ft-green); }
.file-card-icon.k-sheet { background: var(--ft-green-soft); }
.row-icon.k-doc, .file-card-icon.k-doc { color: var(--ft-blue); }
.file-card-icon.k-doc { background: var(--ft-blue-soft); }
.row-icon.k-image, .file-card-icon.k-image { color: var(--ft-amber); }
.file-card-icon.k-image { background: var(--ft-amber-soft); }
.row-icon.k-video, .file-card-icon.k-video { color: var(--ft-violet); }
.file-card-icon.k-video { background: var(--ft-violet-soft); }
.file-card-name {
  font-weight: 550; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color var(--speed);
}
.file-card-meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.file-card-actions { display: flex; gap: 2px; margin-top: 10px; }

/* ---------- Просмотр файла ---------- */
.viewer-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.viewer-stage {
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 14px;
  animation: fadeUp .3s ease;
}
.viewer-img { max-width: 100%; max-height: 76vh; border-radius: var(--radius-s); display: block; }
.viewer-video { max-width: 100%; max-height: 76vh; border-radius: var(--radius-s); display: block; background: #000; }
.viewer-pdf {
  width: 100%; height: 78vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  animation: fadeUp .3s ease;
}
.viewer-text {
  margin: 0; padding: 16px 20px;
  font: 13px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
  white-space: pre-wrap; word-break: break-word;
  color: var(--text);
  max-height: 74vh; overflow: auto;
}
.sheet-tabs { flex-wrap: wrap; }
.sheet-wrap { max-height: 74vh; overflow: auto; }
table.sheet-table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
table.sheet-table th, table.sheet-table td {
  border: 1px solid var(--line);
  padding: 5px 10px;
  white-space: nowrap;
  max-width: 340px;
  overflow: hidden; text-overflow: ellipsis;
}
table.sheet-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--panel-foot);
  color: var(--muted);
  font-weight: 550; text-align: center; font-size: 12.5px;
}
table.sheet-table .rownum {
  background: var(--panel-foot);
  color: var(--muted);
  text-align: right; font-size: 12px;
  position: sticky; left: 0; z-index: 1;
}

/* ---------- Аннотатор (пометки на изображениях и PDF) ---------- */
.ann-toolbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.ann-toolbar .btn.active {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent);
}
.ann-sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }
.ann-color {
  width: 22px; height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--speed), border-color var(--speed);
}
.ann-color:hover { transform: scale(1.12); }
.ann-color.active { border-color: var(--text); }
.ann-hint { font-size: 12.5px; margin-left: auto; }

.ann-wrap { position: relative; }
.ann-stage { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.ann-page {
  position: relative;
  box-shadow: var(--shadow-2);
  border-radius: var(--radius-s);
  overflow: hidden;
  line-height: 0;
  max-width: 100%;
}
.ann-media { max-width: 100%; display: block; }
.ann-overlay {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
}
.ann-pins { position: absolute; inset: 0; pointer-events: none; }
.ann-stage[data-mode="rect"] .ann-page, .ann-stage[data-mode="draw"] .ann-page { cursor: crosshair; touch-action: none; }
.ann-stage[data-mode="pin"] .ann-page { cursor: copy; }
.ann-stage.ann-hidden .ann-overlay, .ann-stage.ann-hidden .ann-pins { display: none; }

.ann-rect {
  fill: transparent;
  stroke-width: 2.5px;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
}
.ann-draw {
  fill: none;
  stroke-width: 2.5px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  pointer-events: stroke;
  cursor: pointer;
}
.ann-pin {
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50% 50% 50% 4px;
  border: 2px solid #fff;
  box-shadow: var(--shadow-2);
  transform: translate(-50%, -100%);
  cursor: pointer;
  pointer-events: auto;
  padding: 0;
  transition: transform var(--speed);
}
.ann-pin:hover { transform: translate(-50%, -100%) scale(1.15); }

.ann-popover {
  position: absolute; z-index: 40;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 12px;
  animation: fadeUp .2s ease;
}
.ann-pop-meta { font-size: 12.5px; margin-bottom: 6px; }
.ann-pop-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; margin-bottom: 8px; }
.ann-popover textarea { margin-bottom: 8px; resize: vertical; }
.ann-pop-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ann-pop-delete { color: var(--danger); }

/* ---------- Модалка камеры ---------- */
.cam-modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: rgba(10, 12, 16, .6);
  animation: fadeIn .2s ease;
}
.cam-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  padding: 14px;
  max-width: 640px; width: calc(100% - 40px);
  animation: fadeUp .3s ease;
}
.cam-box video { width: 100%; border-radius: var(--radius-s); background: #000; display: block; }
.cam-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: center; }

/* ---------- Табы разделов ---------- */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 9px 14px 11px;
  color: var(--muted);
  font-weight: 550; font-size: 14px;
  border-radius: 8px 8px 0 0;
  position: relative;
  transition: color var(--speed), background var(--speed);
}
.tab:hover { color: var(--text); background: var(--surface); }
.tab.active { color: var(--accent); }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
}

.dep-name { display: flex; align-items: center; gap: 8px; }
.dep-branch { color: var(--muted); }

/* ---------- Крошки ---------- */
.crumbs { font-size: 13px; margin-bottom: 4px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.crumb-sep { margin: 0 5px; opacity: .6; }
.crumb-cur { color: var(--text); font-weight: 550; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 15px;
  min-height: 40px; /* иконочные кнопки без текста не ниже текстовых */
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font: inherit; font-weight: 550; font-size: 14px;
  cursor: pointer;
  transition: transform var(--speed), box-shadow var(--speed), background var(--speed), border-color var(--speed);
}
.btn svg { width: 15px; height: 15px; }
.btn-icon { width: 40px; padding: 8px; }
.btn:hover { box-shadow: var(--shadow-1); transform: translateY(-1px); color: var(--text); }
.btn:active { transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
html[data-theme="dark"] .btn-primary { background: #4f46e5; border-color: #4f46e5; }
html[data-theme="dark"] .btn-primary:hover { background: #6366f1; border-color: #6366f1; }
.btn-ghost { border-color: transparent; background: none; }
.btn-ghost:hover { background: var(--bg); box-shadow: none; transform: none; }
.btn-sm { padding: 5px 11px; min-height: 0; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Формы ---------- */
input[type="text"], input[type="password"], input[type="email"], input[type="number"],
input[type="date"], input[type="time"], input[type="search"], input[type="tel"], input[type="url"],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font: inherit; color: var(--text);
  transition: border-color var(--speed), box-shadow var(--speed);
}
input[type="date"] { min-height: 40px; }
input[type="date"]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .65; }

/* --- Пикеры даты и времени (static/js/datepicker.js) --- */
html.dp-on input[type="date"]::-webkit-calendar-picker-indicator,
html.dp-on input[type="time"]::-webkit-calendar-picker-indicator { display: none; }
.dp-wrap { position: relative; display: block; }
.dp-wrap input[type="date"], .dp-wrap input[type="time"], .dp-wrap input.dp-text { padding-right: 34px; }
.dp-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; color: var(--muted);
  /* непрозрачный фон: в Firefox кнопка лежит поверх нативной иконки и прячет её */
  background: var(--surface);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center;
  transition: color var(--speed), background var(--speed);
}
.dp-btn:hover { color: var(--accent); background: var(--accent-soft); }
.dp-btn svg { width: 16px; height: 16px; }
.dp-pop {
  position: fixed; z-index: 80;
  width: 256px; padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  animation: fadeUp .18s ease;
}
.dp-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; padding-left: 6px; }
.dp-title { flex: 1; font-weight: 600; font-size: 14px; }
.dp-nav {
  border: 0; background: none; color: var(--muted);
  width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
  font-size: 17px; line-height: 1;
  display: grid; place-items: center;
  transition: background var(--speed), color var(--speed);
}
.dp-nav:hover { background: var(--bg); color: var(--text); }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-dow { text-align: center; font-size: 11.5px; font-weight: 550; color: var(--muted); padding: 4px 0; }
.dp-day {
  border: 0; background: none; color: var(--text);
  font: inherit; font-size: 13px;
  width: 100%; aspect-ratio: 1; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center;
  transition: background var(--speed), color var(--speed);
}
.dp-day:hover { background: var(--accent-soft); color: var(--accent); }
.dp-day.out { color: var(--placeholder); }
.dp-day.today { box-shadow: inset 0 0 0 1px var(--accent-line); color: var(--accent); font-weight: 600; }
.dp-day.sel { background: var(--accent); color: #fff; font-weight: 600; box-shadow: none; }
.dp-day.sel:hover { background: var(--accent-hover); color: #fff; }
.dp-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--line);
}
.dp-link {
  border: 0; background: none; color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 550;
  padding: 4px 8px; border-radius: 7px; cursor: pointer;
}
.dp-link:hover { background: var(--accent-soft); }
.dp-pop.tp { width: 172px; }
.tp-cols { display: flex; gap: 8px; }
.tp-colwrap { flex: 1; min-width: 0; }
.tp-label { text-align: center; font-size: 11.5px; font-weight: 550; color: var(--muted); padding-bottom: 4px; }
.tp-col {
  max-height: 212px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding-right: 2px;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}
.tp-item {
  flex: 0 0 auto;
  border: 0; background: none; color: var(--text);
  font: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
  padding: 6px 0; border-radius: 8px; cursor: pointer; text-align: center;
  transition: background var(--speed), color var(--speed);
}
.tp-item:hover { background: var(--accent-soft); color: var(--accent); }
.tp-item.sel { background: var(--accent); color: #fff; font-weight: 600; }
.tp-item.sel:hover { background: var(--accent-hover); color: #fff; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
::placeholder { color: var(--placeholder); }

.form-grid {
  /* поля карточек — всегда одним столбцом: заполнять зигзагом неудобно */
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 20px;
  max-width: 680px;
}
.field label { display: block; font-size: 13px; font-weight: 550; margin-bottom: 5px; color: var(--muted); }
.field-wide { grid-column: 1 / -1; }
.field .errorlist { margin: 5px 0 0; padding: 0; list-style: none; color: var(--danger); font-size: 13px; }
.field .helptext { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.field div[id^="id_"] { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.field div[id^="id_"] label {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 14px; font-weight: 400; color: var(--text);
  margin: 0; padding: 4px 0;
}
.form-actions {
  display: flex; gap: 10px; align-items: center;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-foot);
}
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row label { margin: 0; color: var(--text); font-weight: 400; font-size: 14px; }
.flags-row { display: flex; flex-wrap: wrap; gap: 6px 22px; }
.flags-row .check-row { color: var(--text); font-weight: 400; font-size: 14px; }

.inline-form {
  display: flex; gap: 10px; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  padding: 12px;
  margin-bottom: 16px;
  animation: fadeUp .25s ease;
}
.inline-form input[type="text"] { max-width: 320px; }

.danger-zone { margin-top: 14px; display: flex; justify-content: flex-end; }
.danger-zone .btn { color: var(--danger); }
.danger-zone .btn:hover { background: var(--danger-soft); }

.search { position: relative; }
.search input { padding-left: 34px; min-width: 240px; }
.search > svg {
  /* только лупа — прямой потомок; иконки кнопок внутри поля не трогаем */
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}

/* ---------- Тосты ---------- */
.toasts { position: fixed; top: 68px; right: 20px; z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--toast-bg); color: var(--toast-text);
  padding: 10px 16px; border-radius: 10px;
  box-shadow: var(--shadow-2);
  font-size: 14px;
  animation: fadeUp .25s ease;
  transition: opacity .4s, transform .4s;
}
.toast.error { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-line); }
.toast.warning { background: var(--surface); color: var(--ft-amber); border-color: var(--ft-amber); }
.toast.hide { opacity: 0; transform: translateY(-6px); }

/* ---------- Пагинация ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 16px; align-items: center; }
.pager a, .pager span.cur {
  padding: 4px 11px; border-radius: 8px; font-size: 13.5px;
  transition: background var(--speed);
}
.pager a:hover { background: var(--bg); }
.pager span.cur { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- Страница входа ---------- */
body.auth {
  min-height: 100vh;
  display: grid; place-items: center;
  background:
    radial-gradient(600px 400px at 20% 10%, var(--auth-glow-1) 0%, transparent 60%),
    radial-gradient(500px 380px at 85% 90%, var(--auth-glow-2) 0%, transparent 60%),
    var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-2);
  padding: 34px 32px 30px;
  animation: fadeUp .45s cubic-bezier(.16, 1, .3, 1);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-card h1 { font-size: 19px; margin-bottom: 18px; }
.auth-card .field { margin-bottom: 14px; }
.auth-card .btn { margin-top: 6px; }
.auth-error {
  background: var(--danger-soft); color: var(--danger);
  border: 1px solid var(--danger-line);
  border-radius: 10px;
  padding: 9px 13px; margin-bottom: 14px;
  font-size: 13.5px;
  animation: fadeIn .25s ease;
}

/* ---------- Пустые состояния, ошибки ---------- */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.error-page { text-align: center; padding: 70px 20px; animation: fadeUp .3s ease; }
.error-code { font-size: 52px; font-weight: 700; color: var(--dot-off); letter-spacing: -.02em; }

/* ---------- CRM ---------- */
.tab-btn {
  border: 0; background: none; cursor: pointer;
  font: inherit; font-weight: 550; font-size: 14px;
  display: inline-flex; align-items: center; gap: 5px;
}
.tab-caret { font-size: 10px; opacity: .7; }
.tab-dropdown { display: inline-flex; }
.tab-dropdown .dropdown-menu { left: 0; right: auto; top: calc(100% + 8px); min-width: 170px; }
/* раскрытие по наведению (на тач-устройствах остаётся клик) */
@media (hover: hover) {
  .tab-dropdown:not(.dismissed):hover .dropdown-menu { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
  .tab-dropdown .dropdown-menu::before {
    /* невидимый мост над меню: курсор пересекает зазор, не закрывая его */
    content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px;
  }
}
.tab-dropdown .drop-item { display: block; color: var(--text); }
.tab-dropdown .drop-item.current { color: var(--accent); background: var(--accent-soft); }

.product-search input { width: 220px; }
.product-thumb {
  width: 44px; height: 44px;
  object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg);
  display: block;
}
.product-thumb-empty { display: grid; place-items: center; color: var(--dot-off); }
.product-thumb-empty svg { width: 18px; height: 18px; }
.product-photo-current { margin-bottom: 8px; }
.product-photo-current img {
  max-width: 220px; max-height: 220px;
  border-radius: 10px; border: 1px solid var(--line);
  display: block;
}

/* Стадии лидов: чипы и лента в карточке */
.stage-chip {
  display: inline-block;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 550; white-space: nowrap;
}
.sc-blue { background: var(--ft-blue-soft); color: var(--ft-blue); }
.sc-green { background: var(--ft-green-soft); color: var(--ft-green); }
.sc-red { background: var(--ft-red-soft); color: var(--ft-red); }
.sc-violet { background: var(--ft-violet-soft); color: var(--ft-violet); }
.sc-amber { background: var(--ft-amber-soft); color: var(--ft-amber); }
.sc-gray { background: var(--bg); color: var(--muted); }

/* Лента стадий в стиле Б24: мягкие шевроны, пройденные красятся цветом текущей */
.stage-line {
  display: flex; gap: 2px; margin-bottom: 16px;
  border-radius: 10px; overflow: hidden; /* скругляет внешние углы ленты */
}
.stage-form { display: contents; }
.stage-step {
  flex: 1 1 0; min-width: 0;
  border: 0; border-radius: 0;
  padding: 9px 16px 9px 20px;
  text-align: center;
  font: inherit; font-size: 12.5px; font-weight: 550; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--bg); color: var(--muted);
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%, 9px 50%);
  transition: background .22s ease, color .22s ease, opacity .22s ease;
}
.stage-line > :first-child .stage-step,
.stage-line > form:first-child .stage-step {
  clip-path: polygon(0 0, calc(100% - 9px) 0, 100% 50%, calc(100% - 9px) 100%, 0 100%);
  padding-left: 14px;
}
.stage-line > :last-child .stage-step,
.stage-line > form:last-child .stage-step {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 9px 50%);
}
span.stage-step { cursor: default; }
.slc-blue .stage-step.st-done, .slc-blue .stage-step.st-cur { background: var(--ft-blue); color: var(--stage-text); }
.slc-green .stage-step.st-done, .slc-green .stage-step.st-cur { background: var(--ft-green); color: var(--stage-text); }
.slc-red .stage-step.st-done, .slc-red .stage-step.st-cur { background: var(--ft-red); color: var(--stage-text); }
.slc-violet .stage-step.st-done, .slc-violet .stage-step.st-cur { background: var(--ft-violet); color: var(--stage-text); }
.slc-amber .stage-step.st-done, .slc-amber .stage-step.st-cur { background: var(--ft-amber); color: var(--stage-text); }
.slc-gray .stage-step.st-done, .slc-gray .stage-step.st-cur { background: var(--muted); color: var(--stage-text); }
.stage-step.st-done { opacity: 1; }
.stage-step.st-cur { opacity: 1; font-weight: 650; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .3); }
/* превью при наведении: стадии до наведённой загораются её цветом (как в Б24) */
.stage-line.previewing .stage-step { background: var(--bg); color: var(--muted); opacity: 1; }
.stage-line.pv-blue .stage-step.pv { background: var(--ft-blue); color: var(--stage-text); }
.stage-line.pv-green .stage-step.pv { background: var(--ft-green); color: var(--stage-text); }
.stage-line.pv-red .stage-step.pv { background: var(--ft-red); color: var(--stage-text); }
.stage-line.pv-violet .stage-step.pv { background: var(--ft-violet); color: var(--stage-text); }
.stage-line.pv-amber .stage-step.pv { background: var(--ft-amber); color: var(--stage-text); }
.stage-line.pv-gray .stage-step.pv { background: var(--muted); color: var(--stage-text); }

/* Название лида: инлайн-редактор и копирование ссылки */
.lead-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lead-title-text {
  margin: 0; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-radius: 8px; padding: 2px 6px; margin-left: -6px;
  transition: background var(--speed);
}
.lead-title-text:hover { background: var(--hover); }
.lead-title-btn {
  border: 0; background: none; color: var(--muted);
  width: 30px; height: 30px; border-radius: 8px;
  flex: 0 0 auto; cursor: pointer;
  display: grid; place-items: center;
  transition: color var(--speed), background var(--speed);
}
.lead-title-btn:hover { color: var(--accent); background: var(--accent-soft); }
.lead-title-btn svg { width: 16px; height: 16px; }
.lead-title-btn .ic-check { display: none; color: var(--ok); }
.lead-title-btn.ok .ic-link { display: none; }
.lead-title-btn.ok .ic-check { display: block; animation: fadeUp .18s ease; }
.lead-copied { font-size: 12.5px; font-weight: 550; color: var(--ok); animation: fadeUp .18s ease; white-space: nowrap; }
.lead-title-edit { display: flex; align-items: center; gap: 8px; max-width: 620px; }
.lead-title-edit input { font-size: 19px; font-weight: 650; padding: 7px 10px; }
.lead-title-edit.shake { animation: headShake .3s ease; }
@keyframes headShake {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Плавающая панель сохранения карточки — закреплена внизу окна (как в Б24) */
.lead-savebar {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  z-index: 60;
  display: none; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-2);
  white-space: nowrap;
}
form.dirty .lead-savebar { display: flex; animation: fadeUp .18s ease; }
.lead-savebar-hint { font-size: 12.5px; }

/* Поля карточки: режим чтения до клика */
.fld-hidden { display: none !important; }
.fld-view {
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid transparent; border-radius: 10px;
  display: flex; align-items: center;
  cursor: pointer;
  transition: background var(--speed), border-color var(--speed);
}
.fld-view:hover { background: var(--hover); border-color: var(--line); }
.fld-view.fld-empty { color: var(--placeholder); }

/* Маска телефона с кодом страны */
.pm { display: flex; gap: 6px; flex: 1; min-width: 0; }
.pm-code { width: auto; flex: 0 0 auto; padding: 8px 8px; font-size: 13.5px; }
.pm input { flex: 1; min-width: 0; }

/* Контакты лида (formset) */
.contact-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.contact-row select { width: auto; }
.contact-row input[type="text"] { flex: 1; min-width: 180px; }
.contact-del { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); cursor: pointer; }
.contact-del input { accent-color: var(--danger); }
.contact-del span { font-size: 15px; }

/* Карточка лида: слева поля, справа таймлайн */
.lead-layout {
  display: grid;
  /* таймлайну — заметно больше места, чем полям (как в Б24) */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 16px;
  align-items: start;
}
.lead-main { min-width: 0; }
.lead-main .form-grid { max-width: none; }
.lead-timeline { min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.tl-comment { padding: 12px; }
.tl-comment textarea { resize: vertical; }
.tl-comment-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.tl-feed { display: flex; flex-direction: column; gap: 8px; }
.tl-entry {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 14px;
}
.tl-entry.tl-e { background: var(--panel-foot); }
.tl-entry.tl-e .tl-text { color: var(--muted); font-size: 13.5px; }
.tl-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 3px; }
.tl-author { font-weight: 600; font-size: 13px; }
.tl-when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.tl-text { font-size: 14px; word-break: break-word; }
@media (max-width: 1000px) {
  .lead-layout { grid-template-columns: 1fr; }
}

/* Слайдер карточек (как в Б24) */
.slider-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 12, 16, .55);
  animation: fadeIn .15s ease;
}
.slider-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(1500px, calc(100vw - 56px));
  background: var(--bg);
  box-shadow: var(--shadow-2);
  animation: sliderIn .32s cubic-bezier(.16, 1, .3, 1);
}
@keyframes sliderIn { from { transform: translateX(100%); } to { transform: none; } }
.slider-frame { width: 100%; height: 100%; border: 0; display: block; }
.slider-close {
  position: absolute; top: 10px; left: -46px;
  width: 36px; height: 36px;
  border: 0; border-radius: 50%;
  background: var(--surface); color: var(--text);
  font-size: 19px; line-height: 1; cursor: pointer;
  box-shadow: var(--shadow-2);
}
.slider-close:hover { color: var(--danger); }
@media (max-width: 700px) {
  .slider-panel { width: 100vw; }
  .slider-close { left: auto; right: 10px; z-index: 2; }
}
body.slider-open { overflow: hidden; }
body.in-slider .content.slider-content { padding: 20px 22px; max-width: none; }

/* Матрица прав роли */
.role-matrix td { vertical-align: top; }
.role-scope { width: auto; padding: 6px 10px; font-size: 13px; }
.role-stage-grid { display: flex; flex-direction: column; gap: 6px; }
.role-stage { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Расширенный фильтр списка (панель как в Б24) ---------- */
.flt-form { position: relative; }
.flt-search input { padding-right: 38px; }
.flt-btn {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted);
  width: 28px; height: 28px; border-radius: 7px; cursor: pointer;
  display: grid; place-items: center;
  transition: color var(--speed), background var(--speed);
}
.flt-btn:hover { color: var(--accent); background: var(--accent-soft); }
.flt-btn.on { color: var(--accent); }
.flt-btn svg { width: 15px; height: 15px; }

.flt-panel {
  position: fixed; z-index: 45;
  width: min(640px, calc(100vw - 24px));
  overflow-y: auto; overscroll-behavior: contain;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  animation: fadeUp .18s ease;
}
.flt-panel.hidden { display: none; }
.flt-side {
  width: 210px; flex: 0 0 auto;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.flt-side-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 0 8px 8px; }
.flt-preset { display: flex; align-items: center; border-radius: 8px; }
.flt-preset a {
  flex: 1; padding: 7px 10px; border-radius: 8px;
  color: var(--text); font-size: 14px;
  transition: background var(--speed), color var(--speed);
}
.flt-preset a:hover { background: var(--hover); }
.flt-preset.cur a { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.flt-preset-del {
  border: 0; background: none; color: var(--muted);
  width: 24px; height: 24px; border-radius: 6px; cursor: pointer;
  font-size: 15px; line-height: 1;
}
.flt-preset-del:hover { color: var(--danger); background: var(--danger-soft); }
.flt-save-toggle { margin-top: 8px; text-align: left; }
.flt-save { display: flex; gap: 6px; margin-top: 6px; }
.flt-save input { font-size: 13px; padding: 7px 9px; min-width: 0; }

.flt-main { flex: 1; min-width: 0; padding: 14px 16px; }
.flt-fields {
  display: grid;
  grid-template-columns: 1fr; /* поля одним столбцом, как в Б24 */
  gap: 10px;
}
.flt-field label { display: block; font-size: 12px; font-weight: 550; color: var(--muted); margin-bottom: 4px; }
.flt-field input, .flt-field select { padding: 8px 10px; font-size: 13.5px; }
.flt-links { display: flex; gap: 16px; margin: 12px 0 0; }
.flt-link {
  border: 0; background: none; padding: 0;
  color: var(--accent); font-size: 13px; font-weight: 550; cursor: pointer;
}
.flt-link:hover { color: var(--accent-hover); text-decoration: underline; }
.flt-link-muted { color: var(--muted); }
.flt-link-muted:hover { color: var(--text); }
/* пикер полей — модальное окно поверх панели фильтра */
.flt-picker {
  position: absolute; z-index: 5;
  top: 10px; left: 10px; right: 10px;
  display: flex; flex-direction: column; gap: 9px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-2);
  animation: fadeUp .15s ease;
}
.flt-picker.hidden { display: none; }
.flt-picker-head { display: flex; align-items: center; justify-content: space-between; font-weight: 600; font-size: 14px; }
.flt-picker-close {
  border: 0; background: none; color: var(--muted);
  width: 26px; height: 26px; border-radius: 7px;
  font-size: 17px; line-height: 1; cursor: pointer;
}
.flt-picker-close:hover { background: var(--bg); color: var(--text); }
.flt-picker > input { font-size: 13px; padding: 7px 10px; }
.flt-picker-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px 12px; max-height: 240px; overflow-y: auto;
}
.flt-pick { display: flex; align-items: center; gap: 7px; font-size: 13.5px; padding: 3px 2px; cursor: pointer; }
.flt-picker-foot { display: flex; justify-content: flex-end; padding-top: 8px; border-top: 1px solid var(--line); }
.flt-actions { display: flex; gap: 10px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }

/* чипы рендерятся внутри .page-head (инклюд) — order уводит их на строку ниже */
.flt-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; order: 10; width: 100%; }
.flt-loading { opacity: .45; pointer-events: none; transition: opacity .15s; }

/* ---------- Сделки: табы воронок над списком ---------- */
.funnel-tabs {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 12px 14px 4px;
}
.funnel-tab {
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-size: 13px; font-weight: 550;
  transition: background var(--speed), color var(--speed);
}
.funnel-tab:hover { color: var(--text); }
.funnel-tab.active { background: var(--accent-soft); color: var(--accent); }
.funnel-tab-add { padding: 5px 11px; font-weight: 650; }

/* ---------- Карточка сделки: клиент + быстрое создание ---------- */
.contact-pick { display: flex; gap: 8px; align-items: center; }
.contact-pick select { flex: 1; min-width: 0; }
.qc-box {
  display: grid; gap: 8px;
  margin-top: 8px; padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: var(--bg);
}
.qc-actions { display: flex; gap: 8px; }
.flt-chip { text-decoration: none; }
.flt-chip:hover { border-color: var(--danger-line); color: var(--danger); }
.flt-chip b { font-weight: 600; }
.flt-chip-x { opacity: .6; margin-left: 2px; }

@media (max-width: 700px) {
  .flt-panel { flex-direction: column; width: min(calc(100vw - 24px), 480px); }
  .flt-side { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---------- РЦ 49: кассовый лист ---------- */
.cash-add { padding: 16px; overflow: visible; margin-bottom: 16px; }
.cash-add-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.cash-add-row .field { margin: 0; }
.cash-add-row .field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.cash-add-row .grow { flex: 1 1 190px; min-width: 160px; }
.cash-add-row .field input[type="date"], .cash-add-row .field input.dp-text { width: 155px; }
.cash-add-row .field input[type="time"] { width: 118px; }
.cash-f-signer select { width: auto; max-width: 190px; }
.cash-f-cat select { width: auto; max-width: 180px; }
.cash-f-amount input { width: 140px; text-align: right; }
.cash-f-amount input::-webkit-outer-spin-button,
.cash-f-amount input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cash-f-amount input { -moz-appearance: textfield; appearance: textfield; }
.cash-add-errors { margin-top: 10px; }
.cash-add-errors .errorlist { margin: 0; padding: 0; list-style: none; color: var(--danger); font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg-opt {
  display: flex; align-items: center;
  padding: 9px 15px; cursor: pointer;
  font-size: 14px; color: var(--muted);
  user-select: none;
  transition: background var(--speed), color var(--speed);
}
.seg-opt + .seg-opt { border-left: 1px solid var(--line); }
.seg-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.seg-opt[data-k="in"]:has(input:checked) { background: var(--ft-green-soft); color: var(--ok); font-weight: 600; }
.seg-opt[data-k="out"]:has(input:checked) { background: var(--danger-soft); color: var(--danger); font-weight: 600; }

.cash-monthbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.cash-month-nav { display: flex; align-items: center; gap: 6px; }
.cash-month-title { font-weight: 600; min-width: 120px; text-align: center; }
.cash-month-sums { display: flex; flex-wrap: wrap; gap: 2px; margin-left: auto; }

.cash-table th.num, .cash-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cash-in { color: var(--ok); }
.cash-out { color: var(--danger); }
.cash-total { font-weight: 600; }
.cash-neg { color: var(--danger); }
.cash-table tr.cash-day td { background: var(--panel-foot); border-top: 1px solid var(--line); padding: 8px 16px; }
.cash-table tr.cash-day:hover td { background: var(--panel-foot); }
.cash-day-line { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.cash-day-date { font-weight: 600; }
.cash-day-sums { font-size: 13px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.cash-day-sums b { color: var(--text); font-variant-numeric: tabular-nums; }
.cash-day-sums b.cash-neg { color: var(--danger); }
.cash-actions { text-align: right; white-space: nowrap; }
.cash-actions .inline { display: inline-block; }
.chip.cash-edited { font-size: 11px; padding: 0 6px; margin-left: 5px; color: var(--muted); }

/* ---------- Мобильная версия ---------- */
.overlay {
  display: none; position: fixed; inset: 0; z-index: 29;
  background: rgba(20, 24, 31, .35);
  animation: fadeIn .2s ease;
}
@media (max-width: 900px) {
  .side {
    position: fixed; z-index: 30; left: 0;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: none;
  }
  .side.open { transform: none; box-shadow: var(--shadow-2); }
  .app.nav-open .overlay { display: block; }
  .burger { display: block; }
  .content { padding: 16px; }
  .top { padding: 0 14px; }
  .user-name-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Читаемость и доступность общей оболочки ---------- */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}
.skip-link {
  position: fixed; top: 8px; left: 12px; z-index: 100;
  padding: 10px 16px; border-radius: 8px; background: var(--surface);
  box-shadow: var(--shadow-2); transform: translateY(-150%);
}
.skip-link:focus { transform: none; }
.side { height: 100dvh; }
.side .brand, .side-foot { flex-shrink: 0; }
.side .nav { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 3px; margin: -3px; }
.side .nav-link.active::before { left: 0; }
.nav-close { display: none; }
.top { flex-shrink: 0; }
.top-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-btn, .burger { min-width: 40px; min-height: 40px; flex-shrink: 0; }
.user-name-label { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-drop { max-width: min(320px, calc(100vw - 28px)); overflow-wrap: anywhere; }
.tabs { flex-wrap: wrap; }
.grid { grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); }
.table-wrap { overscroll-behavior-x: contain; }
#fltResults table.list { min-width: 960px; }
#fltResults table.list td:first-child { min-width: 240px; }
table.list thead { background: var(--panel-foot); }
table.list tbody tr:focus-within { background: var(--hover); }
.form-actions, .inline-form, .flt-links { flex-wrap: wrap; }
.flt-form { min-width: 0; }
.flt-search input { min-width: 0; }
.flt-field, .flt-field .dp-wrap { min-width: 0; }
.flt-field input, .flt-field select { min-width: 0; }
.flt-save { flex-wrap: wrap; }
.toasts {
  top: auto; bottom: 20px; right: 20px;
  width: min(420px, calc(100vw - 32px)); max-height: 50dvh; overflow-y: auto;
}
.toast { display: flex; align-items: flex-start; gap: 12px; border: 1px solid transparent; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close {
  flex: 0 0 28px; width: 28px; height: 28px; margin: -3px -7px -3px 0;
  border: 0; border-radius: 6px; background: transparent; color: inherit;
  cursor: pointer; font-size: 21px; line-height: 1;
}
.toast-close:hover { background: rgba(127, 127, 127, .16); }
.stage-step:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--text); }
@media (max-width: 900px) {
  .side { visibility: hidden; }
  .side.open { visibility: visible; }
  body.nav-open { overflow: hidden; }
  .nav-close {
    display: grid; place-items: center; position: absolute; top: 16px; right: 8px;
    width: 36px; height: 36px; border: 0; border-radius: 8px;
    background: var(--bg); color: var(--text); font-size: 24px; cursor: pointer;
  }
}
@media (max-width: 700px) {
  .page-head .grow { flex-basis: 100%; }
  .page-head .flt-form { flex-basis: 100%; }
  .page-head .search { width: 100%; }
  .page-head { gap: 10px; }
  .tab { padding-left: 10px; padding-right: 10px; }
  .tab-dropdown .dropdown-menu { left: auto; right: 0; }
  .toasts { right: 16px; bottom: 16px; }
  .stage-line { overflow-x: auto; padding-bottom: 5px; }
  .stage-step { flex: 1 0 140px; }
  body.in-slider .content.slider-content { padding: 54px 16px 16px; }
  .lead-savebar { max-width: calc(100vw - 24px); flex-wrap: wrap; white-space: normal; }
  .auth-card { padding: 28px 24px; }
}
