/* ─────────────────────────────────────────────────────────────
   AMG-CRM — дизайн-система
   ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f7;
  --border: #e4e7ef;
  --border-strong: #d3d7e3;
  --text: #14161f;
  --text-2: #3d4252;
  --muted: #6b7280;
  --sidebar: #0f1220;
  --sidebar-2: #171b2e;
  --sidebar-text: #a9afc3;
  --sidebar-text-active: #ffffff;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-soft-text: #4338ca;
  --success: #15803d;
  --success-soft: #e8f7ee;
  --warning: #b45309;
  --warning-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --info: #0369a1;
  --info-soft: #e6f4fd;
  --violet: #7c3aed;
  --violet-soft: #f1eafe;
  --shadow-sm: 0 1px 2px rgba(16, 20, 35, .05);
  --shadow: 0 4px 16px -4px rgba(16, 20, 35, .10), 0 1px 3px rgba(16, 20, 35, .05);
  --shadow-lg: 0 24px 60px -18px rgba(16, 20, 35, .3), 0 4px 12px rgba(16, 20, 35, .06);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --sidebar-w: 262px;
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #0b0d15;
  --surface: #141824;
  --surface-2: #191e2c;
  --surface-3: #212739;
  --border: #262c3d;
  --border-strong: #333b50;
  --text: #eceef7;
  --text-2: #c3c8d8;
  --muted: #8b93a8;
  --sidebar: #0a0c14;
  --sidebar-2: #121524;
  --accent: #6d68f5;
  --accent-hover: #807cff;
  --accent-soft: #211f45;
  --accent-soft-text: #b3afff;
  --success: #4ade80;
  --success-soft: #10291b;
  --warning: #fbbf24;
  --warning-soft: #2b2010;
  --danger: #f87171;
  --danger-soft: #2c1414;
  --info: #38bdf8;
  --info-soft: #102433;
  --violet: #a78bfa;
  --violet-soft: #221a3d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 4px 18px -6px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8);
}

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.015em; }
p { margin: 0; }
svg { display: block; }

::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ── Каркас ─────────────────────────────────────────────── */

.root { min-height: 100vh; }

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(109, 104, 245, .22), transparent 60%),
    radial-gradient(100% 50% at 100% 100%, rgba(56, 189, 248, .10), transparent 55%),
    var(--sidebar);
  color: var(--sidebar-text);
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
}

.brand-mark {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: linear-gradient(140deg, #6d68f5, #4f46e5 55%, #7c3aed);
  color: #fff;
  box-shadow: 0 6px 18px -6px rgba(109, 104, 245, .9);
  flex: none;
}

.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { color: #7d86a3; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  padding: 14px 10px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #616a86;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13.5px;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.nav-item svg { opacity: .85; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #e7e9f5; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(120deg, rgba(109, 104, 245, .95), rgba(79, 70, 229, .85));
  color: #fff;
  box-shadow: 0 8px 20px -10px rgba(109, 104, 245, .95);
}
.nav-item.active svg { opacity: 1; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-foot { margin-top: auto; padding-top: 14px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
  cursor: pointer;
  width: 100%;
  text-align: left;
  color: #dfe3f2;
}
.user-chip:hover { background: rgba(255, 255, 255, .09); }
.user-chip .meta { min-width: 0; }
.user-chip .name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .role { font-size: 11px; color: #8b93ad; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  height: 64px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 17px; font-weight: 650; }
.topbar .sub { color: var(--muted); font-size: 12.5px; }

.topbar-spacer { flex: 1; }

.search {
  position: relative;
  width: min(340px, 36vw);
}
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); outline: none; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

.content { padding: 26px; flex: 1; }
.content > * { animation: rise .28s cubic-bezier(.22, .8, .3, 1) both; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-head h2 { font-size: 22px; }
.page-head .hint { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Кнопки ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .06s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(140deg, var(--accent), var(--accent-hover));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--accent) 90%, transparent);
}
.btn-primary:hover { background: linear-gradient(140deg, var(--accent-hover), var(--accent)); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--border)); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 8px; }

/* ── Формы ──────────────────────────────────────────────── */

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.textarea { min-height: 92px; resize: vertical; }
.select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }

.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border-radius: 10px;
}
.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 550;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .grow { flex: 1; }

/* ── Карточки ───────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .actions { margin-left: auto; display: flex; gap: 6px; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }

.kpi {
  position: relative;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 550; letter-spacing: .01em; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.kpi .glyph {
  position: absolute;
  right: 14px; top: 14px;
  width: 34px; height: 34px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
}
.kpi.success .glyph { background: var(--success-soft); color: var(--success); }
.kpi.warning .glyph { background: var(--warning-soft); color: var(--warning); }
.kpi.danger .glyph { background: var(--danger-soft); color: var(--danger); }
.kpi.violet .glyph { background: var(--violet-soft); color: var(--violet); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ── Бейджи, пилюли, аватары ────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--surface-3);
  color: var(--text-2);
  white-space: nowrap;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.pill.lead { background: var(--warning-soft); color: var(--warning); }
.pill.active { background: var(--success-soft); color: var(--success); }
.pill.vip { background: var(--violet-soft); color: var(--violet); }
.pill.archived { background: var(--surface-3); color: var(--muted); }
.pill.danger { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.plain::before { display: none; }

.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 12px;
  font-weight: 650;
  color: #fff;
  flex: none;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.lg { width: 46px; height: 46px; font-size: 15px; }
.avatar.xl { width: 64px; height: 64px; font-size: 21px; border-radius: 18px; }

.stack { display: flex; align-items: center; gap: 9px; min-width: 0; }
.stack .col { min-width: 0; }
.stack .t { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack .s { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── Таблица ────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  font-weight: 650;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table th:first-child { padding-left: 18px; }
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table td:first-child { padding-left: 18px; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

/* Подсветка строк звонков по статусу */
.table tbody tr.row-accepted { background: rgba(2, 132, 199, .07); box-shadow: inset 3px 0 0 rgba(2, 132, 199, .55); }
.table tbody tr.row-in-work { background: rgba(217, 119, 6, .08); box-shadow: inset 3px 0 0 rgba(217, 119, 6, .55); }
.table tbody tr.row-done { background: rgba(22, 163, 74, .08); box-shadow: inset 3px 0 0 rgba(22, 163, 74, .55); }
.table tbody tr.row-refused { background: rgba(220, 38, 38, .08); box-shadow: inset 3px 0 0 rgba(220, 38, 38, .5); }

.table tbody tr.row-accepted:hover { background: rgba(2, 132, 199, .14); }
.table tbody tr.row-in-work:hover { background: rgba(217, 119, 6, .15); }
.table tbody tr.row-done:hover { background: rgba(22, 163, 74, .15); }
.table tbody tr.row-refused:hover { background: rgba(220, 38, 38, .15); }

[data-theme="dark"] .table tbody tr.row-accepted { background: rgba(56, 189, 248, .12); }
[data-theme="dark"] .table tbody tr.row-in-work { background: rgba(251, 191, 36, .11); }
[data-theme="dark"] .table tbody tr.row-done { background: rgba(74, 222, 128, .11); }
[data-theme="dark"] .table tbody tr.row-refused { background: rgba(248, 113, 113, .12); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }

/* Подсветка строк Авито по статусу */
.table tbody tr.row-avito-in_work { background: rgba(2, 132, 199, .08); box-shadow: inset 3px 0 0 rgba(2, 132, 199, .5); }
.table tbody tr.row-avito-done { background: rgba(22, 163, 74, .09); box-shadow: inset 3px 0 0 rgba(22, 163, 74, .5); }
.table tbody tr.row-avito-postponed { background: rgba(217, 119, 6, .09); box-shadow: inset 3px 0 0 rgba(217, 119, 6, .5); }
.table tbody tr.row-avito-no_answer { background: rgba(190, 24, 93, .08); box-shadow: inset 3px 0 0 rgba(190, 24, 93, .5); }
.table tbody tr.row-avito-refused { background: rgba(220, 38, 38, .10); box-shadow: inset 3px 0 0 rgba(220, 38, 38, .55); }
.table tbody tr.row-avito-not_target { background: rgba(100, 116, 139, .10); box-shadow: inset 3px 0 0 rgba(100, 116, 139, .45); }
.table tbody tr.row-avito-opt { background: rgba(146, 64, 14, .10); box-shadow: inset 3px 0 0 rgba(146, 64, 14, .5); }

[data-theme="dark"] .table tbody tr.row-avito-in_work { background: rgba(56, 189, 248, .12); }
[data-theme="dark"] .table tbody tr.row-avito-done { background: rgba(74, 222, 128, .11); }
[data-theme="dark"] .table tbody tr.row-avito-postponed { background: rgba(251, 191, 36, .11); }
[data-theme="dark"] .table tbody tr.row-avito-no_answer { background: rgba(244, 114, 182, .12); }
[data-theme="dark"] .table tbody tr.row-avito-refused { background: rgba(248, 113, 113, .13); }
[data-theme="dark"] .table tbody tr.row-avito-not_target { background: rgba(148, 163, 184, .10); }
[data-theme="dark"] .table tbody tr.row-avito-opt { background: rgba(180, 83, 9, .14); }

.select-sm { height: 28px; font-size: 12px; padding: 0 6px; border-radius: 6px; }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--muted);
}
.pagination .spacer { flex: 1; }

/* ── Таймлайн ───────────────────────────────────────────── */

.timeline { position: relative; display: flex; flex-direction: column; gap: 2px; }
.timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 14px; top: 42px; bottom: -6px;
  width: 1px;
  background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-2);
  z-index: 1;
}
.timeline-icon.phone { background: var(--info-soft); color: var(--info); }
.timeline-icon.email { background: var(--violet-soft); color: var(--violet); }
.timeline-icon.meeting { background: var(--warning-soft); color: var(--warning); }
.timeline-icon.system { background: var(--surface-3); color: var(--muted); }
.timeline-body { min-width: 0; padding-top: 3px; }
.timeline-body .text { font-size: 13.5px; color: var(--text); }
.timeline-body .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Канбан ─────────────────────────────────────────────── */

.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.board-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 12px;
  min-height: 220px;
  transition: background .15s, border-color .15s;
}
.board-col.drop-target { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 10px; }
.board-col-head .title { font-size: 12.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.board-col-head .count { margin-left: auto; font-size: 11.5px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 1px 7px; border-radius: 999px; }
.board-cards { display: flex; flex-direction: column; gap: 9px; min-height: 40px; }

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 12px;
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .12s, border-color .15s;
  position: relative;
}
.task-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.task-card.dragging { opacity: .45; transform: rotate(.6deg); }
.task-card .title { font-size: 13.5px; font-weight: 550; line-height: 1.35; }
.task-card .meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.task-card .prio { width: 3px; position: absolute; left: 0; top: 10px; bottom: 10px; border-radius: 4px; background: transparent; }
.task-card.prio-high .prio { background: var(--danger); }
.task-card.prio-normal .prio { background: var(--accent); opacity: .55; }
.task-card.prio-low .prio { background: var(--border-strong); }
.task-card.done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }

.task-del {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: .45;
  transition: opacity .15s, background .15s, color .15s;
}
.task-card:hover .task-del { opacity: 1; }
.task-del:hover { background: var(--danger-soft); color: var(--danger); }
.due { display: inline-flex; align-items: center; gap: 4px; }
.due.overdue { color: var(--danger); font-weight: 600; }
.due.today { color: var(--warning); font-weight: 600; }

/* ── Календарь ──────────────────────────────────────────── */

.calendar { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.calendar-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.calendar-head h3 { font-size: 16px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-dow {
  padding: 9px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 650;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.calendar-cell {
  min-height: 112px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: background .12s;
  overflow: hidden;
  min-width: 0;
}
.calendar-cell:nth-child(7n) { border-right: 0; }
.calendar-cell.other { background: var(--surface-2); }
.calendar-cell.other .day-num { color: color-mix(in srgb, var(--muted) 65%, transparent); }
.calendar-cell:hover { background: var(--surface-2); }
.calendar-cell .day-num { font-size: 12px; font-weight: 600; color: var(--text-2); }
.calendar-cell.today .day-num {
  color: #fff;
  background: var(--accent);
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
}
.cal-event {
  font-size: 11.5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-soft-text);
  border-left: 2px solid var(--accent);
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  min-width: 0;
}
.cal-event.done { opacity: .55; text-decoration: line-through; }
.cal-event.high { background: var(--danger-soft); color: var(--danger); border-left-color: var(--danger); }

/* ── Обновление ─────────────────────────────────────────── */
.update-badge {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}

/* ── Модалки ────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 22, .5);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
  animation: fade .18s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: min(620px, 100%);
  max-height: min(86vh, 880px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  animation: pop .2s cubic-bezier(.2, .9, .3, 1.1) both;
  overflow: hidden;
}
.modal.wide { width: min(820px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 10px; }
.modal-head h3 { font-size: 16.5px; }
.modal-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 8px 20px 4px; overflow-y: auto; }
.modal-foot {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.modal-foot .left { margin-right: auto; }

/* ── Тосты ──────────────────────────────────────────────── */

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  max-width: 420px;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toast-in .22s cubic-bezier(.2, .8, .3, 1) both;
  pointer-events: auto;
}
.toast.out { animation: toast-out .18s ease both; }
.toast .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.toast.success .dot { background: var(--success); }
.toast.error .dot { background: var(--danger); }
.toast.warning .dot { background: var(--warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ── Пустые состояния, скелетоны ────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}
.empty .icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--muted);
}
.empty h4 { font-size: 15px; color: var(--text); }
.empty p { font-size: 13px; max-width: 380px; }

.skeleton {
  border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-3) 25%, color-mix(in srgb, var(--surface-3) 55%, var(--surface)) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-line { height: 12px; margin: 8px 0; }

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Выпадающее меню ────────────────────────────────────── */

.menu {
  position: absolute;
  min-width: 190px;
  padding: 6px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  animation: pop .14s ease both;
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}
.menu button:hover { background: var(--surface-2); }
.menu button.danger { color: var(--danger); }
.menu .sep { height: 1px; background: var(--border); margin: 5px 4px; }

/* ── Детальная карточка клиента ─────────────────────────── */

.hero {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background:
    radial-gradient(120% 100% at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 55%),
    var(--surface);
  margin-bottom: 16px;
}
.hero .name { font-size: 22px; letter-spacing: -.02em; }
.hero .meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.hero-stats { display: flex; gap: 18px; margin-top: 14px; flex-wrap: wrap; }
.hero-stats .stat .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hero-stats .stat .k { font-size: 11.5px; color: var(--muted); }

.info-list { display: flex; flex-direction: column; gap: 14px; }
.info-row { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; }
.info-row svg { margin-top: 2px; color: var(--muted); }
.info-row .k { font-size: 11.5px; color: var(--muted); }
.info-row .v { font-size: 13.5px; word-break: break-word; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab {
  padding: 9px 14px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 550;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.contact-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.contact-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.contact-tile .grow { flex: 1; min-width: 0; }

/* ── Логин ──────────────────────────────────────────────── */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
}
.auth-brand {
  position: relative;
  padding: 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #fff;
  background:
    radial-gradient(90% 70% at 10% 0%, rgba(109, 104, 245, .55), transparent 60%),
    radial-gradient(80% 60% at 90% 100%, rgba(56, 189, 248, .28), transparent 60%),
    linear-gradient(160deg, #14162a, #0c0e18 70%);
  overflow: hidden;
}
.auth-brand::after {
  content: "";
  position: absolute;
  right: -120px; bottom: -160px;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(109, 104, 245, .35), transparent 65%);
}
.auth-brand h1 { font-size: clamp(28px, 3.4vw, 42px); line-height: 1.12; letter-spacing: -.03em; max-width: 15ch; }
.auth-brand p.lead { color: #a9b0c9; font-size: 15px; margin-top: 16px; max-width: 42ch; }
.auth-features { display: flex; flex-direction: column; gap: 14px; margin-top: 36px; }
.auth-feature { display: flex; gap: 12px; align-items: flex-start; color: #cdd3e6; font-size: 13.5px; }
.auth-feature .ic {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; flex: none;
  background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .1);
  color: #b9b4ff;
}
.auth-foot { color: #6f7794; font-size: 12px; }

.auth-panel { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: 24px; letter-spacing: -.02em; }
.auth-card .sub { color: var(--muted); margin-top: 6px; font-size: 13.5px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.auth-form .btn { width: 100%; padding: 11px; }
.auth-hint {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
}
.auth-hint code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; color: var(--text-2); font-size: 11.5px; }

/* ── Мелочи ─────────────────────────────────────────────── */

.divider { height: 1px; background: var(--border); margin: 4px 0; }
.hr-space { height: 16px; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.dot-danger { background: var(--danger); }
.dot-warning { background: var(--warning); }

.bar-chart { display: flex; align-items: flex-end; gap: 5px; height: 84px; padding-top: 6px; }
.bar-chart .bar {
  flex: 1;
  min-width: 4px;
  border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 85%, #fff), color-mix(in srgb, var(--accent) 45%, transparent));
  transition: opacity .15s;
  position: relative;
}
.bar-chart .bar:hover { opacity: .75; }
.bar-chart .bar.zero { background: var(--surface-3); }

.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }

.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }

.breadcrumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--muted); }
.breadcrumbs a:hover { color: var(--text); }

.mobile-only { display: none; }

/* ── Адаптив ────────────────────────────────────────────── */

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(3, minmax(230px, 1fr)); overflow-x: auto; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 74px minmax(0, 1fr); }
  .sidebar { padding: 14px 9px; align-items: center; }
  .brand { padding: 4px 0 14px; }
  .brand-text, .nav-label, .nav-item span.label, .user-chip .meta { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-item .count { display: none; }
  .user-chip { justify-content: center; padding: 8px; }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
}

@media (max-width: 720px) {
  .content { padding: 16px; }
  .topbar { padding: 0 14px; gap: 8px; }
  .search { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .value { font-size: 24px; }
  .board { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .modal { max-height: 92vh; }
  .hero { flex-direction: column; }
  .calendar-cell { min-height: 76px; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media print {
  .sidebar, .topbar, .page-head .actions { display: none; }
  .app { grid-template-columns: 1fr; }
}
/* Компактная таблица чатов Авито */
.table-scroll { overflow-x: auto; }
.table-compact th, .table-compact td { padding: 6px 8px; font-size: 12px; white-space: nowrap; }
.table-compact tbody tr { cursor: pointer; }
.table-compact .select-sm { height: 24px; font-size: 11.5px; padding: 0 4px; }
.table-compact .icon-btn { width: 24px; height: 24px; }
/* Ярко-зелёная подсветка найденной строки чата */
.table tbody tr.avito-hit { background: #b9f6ca !important; box-shadow: inset 4px 0 0 #059669; }
.table tbody tr.avito-hit td { color: #064e3b; }
[data-theme="dark"] .table tbody tr.avito-hit { background: rgba(16, 185, 129, .35) !important; box-shadow: inset 4px 0 0 #34d399; }
[data-theme="dark"] .table tbody tr.avito-hit td { color: #ecfdf5; }
