/* KES CRM — дизайн-система. Брендинг с логотипа: синий гексагон #00A6E2 + чёрный #111. */

:root {
  --brand: #00A6E2;
  --brand-dark: #0086B8;
  --brand-soft: #E6F6FD;
  --ink: #111418;
  --ink-2: #2C3138;
  --muted: #6B7280;
  --muted-2: #9CA3AF;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --border: #E5E7EB;
  --border-strong: #D1D5DB;

  --green: #10B981;
  --green-soft: #D1FAE5;
  --red: #EF4444;
  --red-soft: #FEE2E2;
  --amber: #F59E0B;
  --amber-soft: #FEF3C7;
  --violet: #7B61FF;
  --violet-soft: #EDE9FE;
  --cyan: #06B6D4;
  --cyan-soft: #CFFAFE;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(17,20,24,.04), 0 1px 3px rgba(17,20,24,.06);
  --shadow-md: 0 4px 12px rgba(17,20,24,.08);
  --shadow-lg: 0 12px 32px rgba(17,20,24,.12);

  --sidebar-w: 248px;
  --header-h: 60px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%; /* не «раздувать» текст в альбомной на iOS */
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  background: var(--ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .logo-mark { flex-shrink: 0; }
.sidebar-brand .logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.sidebar-brand .logo-text b { font-size: 16px; letter-spacing: .5px; }
.sidebar-brand .logo-text span { font-size: 11px; opacity: .65; }

.sidebar-tenant {
  padding: 10px 18px;
  font-size: 11px;
  color: rgba(255,255,255,.5);
  text-transform: uppercase;
  letter-spacing: .8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 12px;
}
.sidebar-nav button {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  color: rgba(255,255,255,.78);
  font-size: 13.5px;
  text-align: left;
  border-radius: var(--radius-sm);
  margin: 1px 0;
  transition: background .15s, color .15s;
}
.sidebar-nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav button.active {
  background: var(--brand);
  color: #fff;
  font-weight: 600;
}
.sidebar-nav button .icon { font-size: 16px; line-height: 1; }
.sidebar-nav button .badge {
  margin-left: auto;
  background: rgba(255,255,255,.18);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}
.sidebar-nav button.active .badge { background: rgba(0,0,0,.25); }

/* ----- Группа «Сделки» с раскрывающимся списком воронок ----- */
.nav-group { margin: 1px 0; }
.nav-group-row { display: flex; align-items: center; gap: 2px; }
.nav-group-main { flex: 1; }
.sidebar-nav .nav-group-toggle {
  width: 26px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: 0; cursor: pointer;
  color: rgba(255,255,255,.6); font-size: 11px;
  padding: 9px 0; margin: 0;
  border-radius: var(--radius-sm);
  transition: transform .15s, color .15s, background .15s;
}
.sidebar-nav .nav-group-toggle:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-group.open .nav-group-toggle { transform: rotate(90deg); }
.nav-sub { display: none; flex-direction: column; margin: 2px 0 4px 14px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.12); }
.nav-group.open .nav-sub { display: flex; }
.pipe-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer;
  color: rgba(255,255,255,.7); font-size: 12.5px;
  transition: background .15s, color .15s;
}
.pipe-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.pipe-item.active { background: rgba(0,166,226,.22); color: #fff; font-weight: 600; }
.pipe-item .pipe-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; opacity: .6; }
.pipe-item .pipe-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-item .pipe-actions { display: none; gap: 4px; flex: none; }
.pipe-item:hover .pipe-actions { display: flex; }
.pipe-actions span { width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; font-size: 12px; color: rgba(255,255,255,.6); }
.pipe-actions span:hover { background: rgba(255,255,255,.16); color: #fff; }
.sidebar-nav .pipe-add {
  width: 100%; text-align: left; margin-top: 2px;
  padding: 7px 9px; background: transparent; border: 0; cursor: pointer;
  color: rgba(255,255,255,.55); font-size: 12.5px; border-radius: var(--radius-sm);
}
.sidebar-nav .pipe-add:hover { background: rgba(255,255,255,.06); color: #fff; }

/* Выпадающий выбор воронок (заголовок раздела «Сделки») */
.pipe-dd { position: relative; display: inline-block; }
.pipe-dd-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0; cursor: pointer; user-select: none;
  padding: 6px 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fff, #F6FBFE);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(17,20,24,.05);
  transition: color .12s, background .12s, border-color .12s, box-shadow .12s;
}
.pipe-dd-trigger:hover {
  color: var(--brand); border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(0,166,226,.18);
}
.pipe-dd.open .pipe-dd-trigger {
  color: var(--brand); border-color: var(--brand);
  background: rgba(0,166,226,.08);
  box-shadow: 0 2px 10px rgba(0,166,226,.20);
}
.pipe-dd-trigger:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.pipe-dd-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.pipe-dd-caret {
  font-size: 12px; opacity: .7; color: var(--ink);
  transition: transform .18s ease, opacity .12s;
}
.pipe-dd-trigger:hover .pipe-dd-caret, .pipe-dd.open .pipe-dd-caret { opacity: 1; }
.pipe-dd.open .pipe-dd-caret { transform: rotate(180deg); }
.pipe-dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  min-width: 264px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(17,20,24,.14); padding: 6px;
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s ease, transform .15s ease, visibility .15s;
}
.pipe-dd.open .pipe-dd-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.pipe-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; color: var(--ink);
}
.pipe-dd-item:hover { background: #F3F4F6; }
.pipe-dd-item.active { background: rgba(0,166,226,.10); font-weight: 600; }
.pipe-dd-item > svg { color: var(--brand); flex: none; }
.pipe-dd-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); flex: none; opacity: .3; }
.pipe-dd-item.active .pipe-dd-dot { opacity: 1; }
.pipe-dd-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pipe-dd-actions { display: inline-flex; gap: 2px; margin-left: auto; opacity: 0; transition: opacity .12s; }
.pipe-dd-item:hover .pipe-dd-actions { opacity: 1; }
.pipe-dd-act { display: inline-flex; padding: 4px; border-radius: 6px; color: var(--muted); }
.pipe-dd-act:hover { background: rgba(17,20,24,.07); color: var(--ink); }
.pipe-dd-act svg { color: inherit; }
.pipe-dd-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.pipe-dd-create {
  width: 100%; display: flex; align-items: center; gap: 8px; justify-content: flex-start;
  padding: 9px 10px; border: 0; background: none; cursor: pointer;
  font-size: 13.5px; font-weight: 600; color: var(--brand); border-radius: 8px;
}
.pipe-dd-create:hover { background: rgba(0,166,226,.10); }

/* Стилизованный селект «Изменить статус» (модалка отгрузки) — со своей стрелкой */
.status-select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  height: 36px; padding: 0 34px 0 12px;
  border: 1px solid var(--border); border-radius: 8px; background-color: #fff;
  font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23111418' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
.status-select:hover { border-color: var(--brand); }
.status-select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,166,226,.13); }

.sidebar-foot {
  padding: 10px 14px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 11px;
  color: rgba(255,255,255,.4);
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar-foot button {
  background: transparent; color: rgba(255,255,255,.6); border: 0; font-size: 11px;
}
.sidebar-foot button:hover { color: #fff; }

/* ---------- Header ---------- */
.header {
  grid-area: header;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 18px;
}
.header-title { font-size: 17px; font-weight: 600; color: var(--ink); }
.header-title .crumb { color: var(--muted); font-weight: 400; margin-right: 6px; }

.header-search {
  flex: 1; max-width: 480px;
  position: relative;
}
.header-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, background .15s;
}
.header-search input:focus { border-color: var(--brand); background: #fff; }
.header-search::before {
  content: '⌕';
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); font-size: 16px;
}

.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 16px;
  position: relative;
}
.icon-btn:hover { background: var(--bg); border-color: var(--border); }
.icon-btn .dot {
  display: none;                 /* по умолчанию точки нет — просто колокольчик */
  position: absolute; top: 7px; right: 8px;
  width: 8px; height: 8px;
  background: var(--red);
  border-radius: 50%;
  border: 2px solid #fff;
}
.icon-btn .dot.show { display: block; } /* красная точка при наличии уведомлений */

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}
.user-chip .name { font-size: 13px; font-weight: 500; line-height: 1.2; }
.user-chip .role { font-size: 11px; color: var(--muted); line-height: 1.2; }

/* ---------- Main ---------- */
.main {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
  padding: 24px 28px 60px;
}
.view { display: none; }
.view.active { display: block; }

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.page-head .actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
/* Кнопки CRM — компактные, минималистичные, единый стиль */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px; font-weight: 500; white-space: nowrap;
  cursor: pointer;
  transition: background .13s ease, border-color .13s ease, box-shadow .13s ease, transform .04s ease;
}
.btn:hover { background: var(--bg); border-color: #D1D5DB; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-primary:active { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: transparent; }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

/* ---------- Cards / Stats ---------- */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .more { font-size: 12px; color: var(--muted); }

.stat .stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat .stat-delta { font-size: 12px; margin-top: 4px; }
.stat .stat-delta.up { color: var(--green); }
.stat .stat-delta.down { color: var(--red); }
.stat .stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: var(--brand-soft); color: var(--brand);
  float: right;
}

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto; /* широкие таблицы прокручиваются по горизонтали (планшет/телефон), не ломая вёрстку */
  -webkit-overflow-scrolling: touch;
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
.table-toolbar input,
.table-toolbar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
}
.table-toolbar input { min-width: 220px; }
.table-toolbar input:focus, .table-toolbar select:focus { border-color: var(--brand); }
.table-toolbar .spacer { flex: 1; }

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data thead th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  padding: 10px 14px;
  background: #FAFBFC;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr { cursor: pointer; transition: background .12s; }
table.data tbody tr:hover { background: #FAFBFC; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .strong { font-weight: 600; }
table.data .muted { color: var(--muted); font-size: 12px; }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 500;
  background: var(--bg); color: var(--ink-2);
  white-space: nowrap;
}
.pill.dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; display: inline-block;
}
.pill-success { background: var(--green-soft); color: #047857; }
.pill-danger  { background: var(--red-soft);   color: #B91C1C; }
.pill-warn    { background: var(--amber-soft); color: #B45309; }
.pill-info    { background: var(--brand-soft); color: var(--brand-dark); }
.pill-violet  { background: var(--violet-soft); color: #5B21B6; }
.pill-cyan    { background: var(--cyan-soft);  color: #0E7490; }
.pill-muted   { background: #F3F4F6; color: var(--muted); }

.tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  background: #F3F4F6; color: var(--muted);
  margin-right: 4px;
}

/* ---------- Kanban ---------- */
.kanban {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 12px;
  max-width: 100%;
  min-width: 0;
  scrollbar-width: thin;
}
.k-col {
  flex: 0 0 250px;            /* все этапы одного фиксированного размера */
  width: 250px; min-width: 250px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
  min-height: 200px;
}
.k-col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 7px;
}
.k-head-top { display: flex; align-items: flex-start; gap: 8px; }
.k-head-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 24px; }
.k-head-bottom .stage-sum { font-size: 12px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.k-head-bottom .stage-actions { display: inline-flex; gap: 6px; flex: none; }
.k-col-head .stage-grip { margin-top: 2px; }
.k-col-head .stage-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 4px; flex: none;
}
/* Название этапа: видно целиком — переносится, без обрезки и многоточия */
.k-col-head .stage-label {
  font-weight: 600; font-size: 12px; flex: 1; min-width: 0;
  white-space: normal; overflow-wrap: anywhere; word-break: break-word;
  line-height: 1.3; padding-top: 1px;
}
.k-col-head .stage-label-edit {
  cursor: text; padding: 2px 5px; border-radius: 5px; outline: none;
}
.k-col-head .stage-label-edit:hover { background: #fff; box-shadow: inset 0 0 0 1px var(--border); }
.k-col-head .stage-label-edit:focus { background: #fff; box-shadow: 0 0 0 2px rgba(0,166,226,.25); }
.k-col-head .stage-count {
  background: var(--bg); color: var(--muted);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  flex: none;
}
.k-col-head .stage-add {
  flex: none; width: 22px; height: 22px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer; color: var(--brand);
  font-size: 15px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.k-col-head .stage-add:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.k-col-head .stage-del {
  flex: none; width: 22px; height: 22px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer; color: var(--muted);
  font-size: 16px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.k-col-head .stage-del:hover { background: #EF4444; color: #fff; border-color: #EF4444; }
.k-col-head .stage-gear {
  flex: none; width: 22px; height: 22px; border: 1px solid var(--border);
  background: #fff; border-radius: 6px; cursor: pointer; color: var(--muted);
  font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.k-col-head .stage-gear:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

.bulk-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 10px;
  background: #E6F6FD; border: 1px solid var(--brand); border-radius: 8px;
  font-size: 13px;
}
.bulk-bar > span { margin-right: auto; }
.bulk-head { font-size: 14px; margin: 0 0 12px; padding: 9px 12px; background: #E6F6FD; border-radius: 8px; color: #0C5A8A; }
.k-col-body {
  padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  flex: 1;
}
.k-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.k-card:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.k-card .k-card-no { font-size: 11px; color: var(--muted); }
.k-card .k-card-title { font-weight: 500; margin: 4px 0 6px; line-height: 1.3; color: var(--ink); }
.k-card .k-card-foot { display: flex; align-items: center; justify-content: space-between; }
.k-card .k-card-amount { font-weight: 600; }
.k-card .avatar { width: 22px; height: 22px; font-size: 10px; }

/* ---------- Catalog ---------- */
.cat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.cat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s, transform .1s;
}
.cat-tile:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.cat-tile .cat-icon { font-size: 28px; }
.cat-tile .cat-name { font-weight: 500; line-height: 1.3; }
.cat-tile .cat-count { font-size: 12px; color: var(--muted); margin-top: auto; }

/* ---------- Inline stock indicator ---------- */
.stock-bar {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.stock-bar .bar {
  width: 60px; height: 6px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.stock-bar .bar-fill {
  height: 100%;
  background: var(--green);
  transition: width .3s;
}
.stock-bar.low .bar-fill { background: var(--amber); }
.stock-bar.crit .bar-fill { background: var(--red); }

/* ---------- Activity feed ---------- */
.activity {
  display: flex; flex-direction: column; gap: 14px;
}
.activity-item {
  display: flex; gap: 12px;
}
.activity-item.clickable {
  cursor: pointer; padding: 6px 8px; margin: 0 -8px;
  border-radius: var(--radius-sm); transition: background .15s;
}
.activity-item.clickable:hover { background: var(--bg); }

/* ===== Матрица доступа по ролям ===== */
.role-matrix { width: auto; min-width: 100%; }
.role-matrix th, .role-matrix td { white-space: nowrap; }
.role-head { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.role-del {
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted-2); font-size: 13px; line-height: 1;
  width: 18px; height: 18px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; transition: background .15s, color .15s;
}
.role-del:hover { background: var(--red-soft); color: var(--red); }

/* ===== Боковая панель фильтров (drawer) ===== */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(17,20,24,.35);
  opacity: 0; visibility: hidden; transition: opacity .2s; z-index: 60;
}
.drawer-backdrop.open { opacity: 1; visibility: visible; }
.filter-drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 340px; max-width: 90vw;
  background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform .25s ease; z-index: 61;
  display: flex; flex-direction: column;
}
.filter-drawer.open { transform: translateX(0); }
.filter-drawer .fd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
}
.filter-drawer .fd-close {
  width: 30px; height: 30px; border: 0; background: transparent; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--muted); border-radius: var(--radius-sm);
}
.filter-drawer .fd-close:hover { background: var(--bg); color: var(--ink); }
.filter-drawer .fd-body { padding: 16px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.filter-drawer .fd-foot { padding: 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.filter-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.filter-group .row2 { display: flex; gap: 8px; }
.filter-group input, .filter-group select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; outline: none; background: #fff;
}
.filter-group input:focus, .filter-group select:focus { border-color: var(--brand); }
.activity-item .av-dot {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-item .av-body { font-size: 13px; line-height: 1.4; }
.activity-item .av-time { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Empty / placeholder ---------- */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty .em-icon { font-size: 36px; opacity: .5; }
.empty .em-text { margin-top: 8px; font-size: 13px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17,20,24,.45);
  display: none; align-items: center; justify-content: center;
  z-index: 100;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-head button { background: transparent; border: 0; font-size: 22px; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap;
}

/* ---------- Карточка сделки (широкое модальное окно) ---------- */
.modal.modal-xl { max-width: 1200px; width: 96vw; height: 90vh; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.modal-xl .modal-head { flex: none; }
.modal.modal-xl .modal-body { flex: 1; min-height: 0; padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.modal.modal-xl .modal-foot { flex: none; }
.deal-modal { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.deal-modal .funnel-steps { flex: none; }
.deal-modal .deal-stagebar { flex: none; }
/* убираем скроллбары внутри карточки сделки (скролл остаётся) */
.modal.modal-xl * { scrollbar-width: none; }
.modal.modal-xl *::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* ---------- Этап сделки: компактный выпадающий список (замена воронки-шевронов) ---------- */
/* На десктопе сверху — воронка-шевроны (.funnel-steps); дропдаун этапов скрыт.
   На мобильном (≤860px) — наоборот (см. медиазапрос ниже). */
.deal-stagebar { display: none; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.stage-dd { position: relative; }
.stage-dd-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px;
  background: #fff; font-size: 13px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.stage-dd-btn:hover { border-color: var(--brand); }
.stage-dd-btn:disabled { cursor: default; opacity: .9; }
.stage-dd-btn.open { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,166,226,.12); }
.stage-dd-btn .stage-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stage-dd-btn .stage-caret { color: var(--muted); font-size: 11px; }
.stage-dd-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 40;
  min-width: 240px; max-height: 320px; overflow-y: auto;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px;
}
.stage-dd-item { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.stage-dd-item:hover { background: var(--brand-soft); }
.stage-dd-item.active { background: var(--brand-soft); font-weight: 700; color: var(--brand-dark); }
.stage-dd-item .stage-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stage-dd-item .stage-dd-lbl { flex: 1; }
.stage-dd-item .stage-dd-check { color: var(--brand); font-weight: 700; }

/* Вкладка «Сделка» (инфо/клиент) — только на мобильном; на десктопе левая колонка видна всегда */
.chat-tab[data-tab="info"] { display: none; }
.chat-pane[data-pane="info"] { padding: 0; }
.chat-pane[data-pane="info"] .deal-left { flex: 1; min-height: 0; width: 100%; border: 0; }

.funnel-steps { display: flex; gap: 3px; padding: 14px 18px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.funnel-step {
  flex: 1 1 0; min-width: 92px; padding: 8px 10px 8px 22px;
  background: #F1F3F5; color: #6B7280; font-size: 11.5px; font-weight: 600; white-space: nowrap;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%, 13px 50%);
  cursor: pointer; text-align: center; transition: background .15s;
}
.funnel-step:first-child { clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 50%, calc(100% - 13px) 100%, 0 100%); padding-left: 14px; }
.funnel-step.done { background: #DBEAFE; color: #1D4ED8; }
.funnel-step.active { background: var(--brand); color: #fff; }

.deal-split { display: grid; grid-template-columns: 300px 1fr; flex: 1; min-height: 0; }
.deal-left { padding: 14px 16px; border-right: 1px solid var(--border); overflow-y: auto; background: #FAFBFC; }
.deal-section { margin-bottom: 14px; }
.deal-section:last-of-type { margin-bottom: 6px; }
.deal-left .form-row { margin-bottom: 9px; gap: 3px; }
.deal-left .section-title { margin-bottom: 8px; }
.deal-left .form-row input, .deal-left .form-row select, .deal-left .form-row textarea { width: 100%; box-sizing: border-box; }
.deal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.line-items-table { width: 100%; table-layout: fixed; font-size: 12.5px; border-collapse: collapse; }
.line-items-table th { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: none; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.line-items-table td { padding: 6px 6px; vertical-align: middle; border-bottom: 1px solid #F3F4F6; }
.line-items-table th.num, .line-items-table td.num { text-align: right; white-space: nowrap; }
.line-items-table td:first-child > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Комбобокс «список по клику + свой ввод» (например, поле «Транспорт») */
.combo { position: relative; display: inline-flex; align-items: center; width: 100%; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.combo input { flex: 1; min-width: 0; border: 0 !important; background: transparent; outline: none;
  padding: 8px 6px 8px 10px; font: inherit; color: inherit; width: auto; }
.combo-arrow { flex: none; border: 0; background: transparent; cursor: pointer; padding: 4px 9px;
  color: var(--muted); font-size: 12px; line-height: 1; }
.combo-arrow:hover { color: var(--brand); }
.combo-menu { position: absolute; top: calc(100% + 3px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.13);
  max-height: 220px; overflow-y: auto; padding: 4px; }
.combo-item { padding: 7px 10px; cursor: pointer; font-size: 13px; border-radius: 6px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.combo-item:hover { background: #F1F5F9; }

/* Единый размер интерактивных полей в карточке «Отгрузка» (селекты, комбобокс) */
.ship-control { width: 100%; max-width: 180px; box-sizing: border-box; }
select.ship-control { height: 34px; padding: 0 30px 0 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13px; }
.combo.ship-control { min-height: 34px; }
.combo.ship-control input { padding: 7px 6px 7px 10px; }

.line-items-table input.qty {
  width: 100%; min-width: 0; box-sizing: border-box; padding: 5px 4px; text-align: right; font-size: 12.5px;
  color: var(--ink); font-family: inherit; font-variant-numeric: tabular-nums;
  border: 1px solid #EDEFF2; border-radius: 6px; background: #F4F6F8;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.line-items-table input.qty:hover { background: #EEF1F4; border-color: #E2E6EA; }
.line-items-table input.qty:focus {
  outline: none; background: #fff; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,166,226,.13);
}
.line-items-table input[type="number"] { -webkit-appearance: none; -moz-appearance: textfield; appearance: none; }
.line-items-table input[type="number"]::-webkit-outer-spin-button,
.line-items-table input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.line-items-table .x-btn { border: 0; background: transparent; color: #EF4444; font-size: 18px; line-height: 1; cursor: pointer; padding: 0 2px; }
.price-chip {
  display: inline-block; font-size: 10.5px; line-height: 1; padding: 3px 5px; border-radius: 5px;
  background: #EEF4F8; color: #2A5566; border: 1px solid #DCE7EE; cursor: pointer; white-space: nowrap;
  font-variant-numeric: tabular-nums; transition: background .12s, border-color .12s;
}
.price-chip:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.price-chip.off { background: #F3F4F6; color: #9CA3AF; border-color: #ECEEF1; cursor: default; }
.price-chip.off:hover { background: #F3F4F6; color: #9CA3AF; border-color: #ECEEF1; }
.price-chip.active { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; box-shadow: 0 0 0 2px rgba(0,166,226,.22); }
.price-chip.active:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.deal-right { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
/* min-width:0 — чтобы широкий контент раздела (например, таблица счетов) не
   распирал колонку и не «съезжали» все разделы; вместо этого скроллится внутри. */
.chat-pane { min-width: 0; }
.section-title { font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; color: #9CA3AF; margin: 0 0 12px; }

.client-block { display: flex; flex-direction: column; gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.client-block .client-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.client-block .avatar { flex: none; width: 38px; height: 38px; font-size: 14px; }
.client-block .who { flex: 1; min-width: 0; overflow: hidden; }
.client-block .who .nm { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-block .who .ph { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-block .cact { display: flex; gap: 6px; }
.client-block .cact button { flex: 1; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--brand); }

.chat-tabs { display: flex; gap: 2px; padding: 10px 14px 0; border-bottom: 1px solid var(--border); }
.chat-tab { padding: 8px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.chat-tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.chat-pane { flex: 1; min-height: 0; display: none; flex-direction: column; }
.chat-pane.active { display: flex; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; background: #ECE5DD; display: flex; flex-direction: column; gap: 6px; }
.chat-date { align-self: center; background: #fff; color: #6B7280; font-size: 11px; padding: 3px 12px; border-radius: 999px; margin: 6px 0; box-shadow: var(--shadow-sm); }
.msg { max-width: 80%; padding: 7px 10px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-sm); }
.msg.out { align-self: flex-end; background: #DCF8C6; }
.msg.in { align-self: flex-start; background: #fff; }
.msg .time { font-size: 10px; color: #98A0A6; margin-top: 3px; text-align: right; }
.msg-file { display: flex; align-items: center; gap: 10px; }
.msg-file .fi { width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center; background: #EEF2FF; border-radius: 8px; color: #4F46E5; }
.msg-file .fn { font-weight: 600; font-size: 12.5px; }
.msg-file .fd { font-size: 11px; color: var(--muted); }
.msg-sys { align-self: center; display: flex; align-items: center; gap: 6px; background: #ECFDF5; color: #047857; font-size: 12px; padding: 5px 12px; border-radius: 999px; }
.chat-input { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); background: #fff; }
.chat-input input { flex: 1; border: 1px solid var(--border); border-radius: 999px; padding: 9px 14px; font-size: 13px; outline: none; }
.chat-input input:focus { border-color: var(--brand); }
.chat-input button { background: transparent; border: 0; cursor: pointer; color: var(--brand); padding: 6px; display: inline-flex; }
.chat-comments { flex: 1; padding: 14px; gap: 10px; overflow-y: auto; }
.chat-comments.active { display: flex; flex-direction: column; }
.chat-items { flex: 1; padding: 14px; overflow-y: auto; }
.chat-comments textarea { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 13px; font-family: inherit; outline: none; resize: vertical; min-height: 120px; }

@media (max-width: 860px) {
  /* Карточка сделки на телефоне: одна колонка (инфо-панель уезжает во вкладку «Сделка»),
     карточка заполняет модалку, прокрутка — внутри активной вкладки, разделы листаются свайпом. */
  .modal.modal-xl { height: 92vh; max-height: 92vh; }
  .deal-split { grid-template-columns: 1fr; }
  .deal-right { min-height: 0; }
  /* на мобильном: дропдаун этапов вместо воронки-шевронов */
  .funnel-steps { display: none; }
  .deal-stagebar { display: flex; padding: 10px 12px; }
  .deal-actions button { flex: 1 1 auto; }

  /* «Сделка» — вкладка; вкладки ПЕРЕНОСятся, чтобы все были видны (ничего не скрыто) */
  .chat-tab[data-tab="info"] { display: block; }
  .chat-tabs { flex-wrap: wrap; overflow: visible; white-space: normal; padding: 8px 10px; gap: 5px 6px; }
  .chat-tab { flex: none; padding: 6px 10px; font-size: 12.5px; border-bottom: 0; border-radius: 7px; background: #F1F3F5; color: var(--muted); }
  .chat-tab.active { background: var(--brand-soft); color: var(--brand-dark); }

  /* Товары — вертикальные карточки вместо широкой таблицы (без перегруза в одну строку) */
  .chat-items { overflow-x: visible; }
  .line-items-table { min-width: 0; }
  .line-items-table thead { display: none; }
  .line-items-table, .line-items-table tbody, .line-items-table tr, .line-items-table td { display: block; width: auto; }
  .line-items-table tr { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  .line-items-table td { border: 0; padding: 4px 0; text-align: left; white-space: normal; }
  .line-items-table td.num { text-align: left; }
  .line-items-table td.li-name { font-weight: 600; padding-bottom: 6px; }
  .line-items-table td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 3px; }
  .line-items-table td.li-del { text-align: right; padding-top: 2px; }
  .line-items-table input.qty { width: 100%; max-width: 200px; height: 38px; font-size: 15px; }

  /* Таблицы внутри разделов (счета и т.п.) — карточками, без распирания/съезда */
  table.mobile-cards thead { display: none; }
  table.mobile-cards, table.mobile-cards tbody, table.mobile-cards tr, table.mobile-cards td { display: block; width: auto; }
  table.mobile-cards tr { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-bottom: 8px; background: #fff; }
  table.mobile-cards td { border: 0; padding: 3px 0; text-align: left; white-space: normal; }
  table.mobile-cards td.num { text-align: left; }
  table.mobile-cards td[data-label]::before { content: attr(data-label) ': '; color: var(--muted); font-size: 11px; font-weight: 500; }

  /* плавный переход между разделами при свайпе/тапе */
  .chat-pane.active { animation: dealPaneIn .18s ease; }
}

@keyframes dealPaneIn { from { opacity: .4; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-row label { font-size: 12px; color: var(--muted); font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--brand); }

/* ---------- Иконки (инлайн-SVG вместо эмодзи) ---------- */
svg.ic { display: inline-block; vertical-align: -0.15em; flex: none; }
.sidebar-nav .icon { display: inline-flex; align-items: center; }
.sidebar-nav .icon svg.ic { width: 18px; height: 18px; }
.icon-btn svg.ic { width: 18px; height: 18px; }
.k-col-head svg.ic, .stat-icon svg.ic { width: 18px; height: 18px; }
.stat-icon svg.ic { width: 22px; height: 22px; }
button svg.ic { vertical-align: -0.18em; }

/* ---------- Унифицированный вид select / date / time (скрываем нативный браузерный вид) ---------- */
select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding: 8px 30px 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--ink, #111827);
  background-color: #fff;
  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.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  outline: none; cursor: pointer; line-height: 1.3;
}
select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,166,226,.12); }
select:disabled { background-color: #F9FAFB; color: var(--muted); cursor: not-allowed; }

input[type="date"], input[type="time"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--ink, #111827);
  background: #fff; outline: none; cursor: pointer;
}
input[type="date"]:focus, input[type="time"]:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(0,166,226,.12); }
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer; opacity: .5; padding: 2px; border-radius: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover { opacity: .9; background: #F3F4F6; }

/* Поле даты CRM: текстовый ввод + кнопка-календарь */
.crm-datefield { display: flex; gap: 6px; align-items: center; position: relative; }
.crm-cal-btn { flex: none; padding: 7px 10px; line-height: 1; }
.crm-cal-native { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- Detail panels ---------- */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Misc ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.gap-md { gap: 14px; }
.flex-1 { flex: 1; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

.bar-mini {
  height: 6px; background: var(--bg); border-radius: 999px; overflow: hidden;
}
.bar-mini > div { height: 100%; background: var(--brand); }

/* Charts (CSS only) */
.bar-chart {
  display: flex; align-items: flex-end; gap: 8px;
  height: 180px;
  padding: 0 4px;
}
.bar-chart .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 4px;
  transition: opacity .15s;
}
.bar-chart .bar:hover { opacity: .85; }
.bar-chart .bar .lbl {
  position: absolute; bottom: -22px; left: 0; right: 0;
  text-align: center; font-size: 11px; color: var(--muted);
}
.bar-chart .bar .val {
  position: absolute; top: -20px; left: 0; right: 0;
  text-align: center; font-size: 11px; color: var(--ink); font-weight: 600;
}

/* Funnel */
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-row {
  display: grid;
  grid-template-columns: 140px 1fr 80px;
  align-items: center; gap: 10px;
  font-size: 13px;
}
.funnel-row .fn-label { color: var(--ink-2); }
.funnel-row:hover .fn-label { color: var(--brand); text-decoration: underline; }
.funnel-row .fn-bar { background: var(--bg); height: 22px; border-radius: 6px; overflow: hidden; position: relative; }
.funnel-row .fn-bar > div { height: 100%; background: var(--brand); border-radius: 6px; }
.funnel-row .fn-val { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  max-width: 360px;
}
.toast {
  background: var(--ink); color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 10px;
  animation: toast-in .2s ease-out;
}
.toast.info    { background: #1F2937; }
.toast.success { background: #047857; }
.toast.warn    { background: #B45309; }
.toast.error   { background: #B91C1C; }
.toast .toast-icon { flex-shrink: 0; }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ---------- Notification dropdown ---------- */
.dropdown {
  position: absolute;
  top: calc(var(--header-h) - 6px); right: 110px;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  overflow: hidden;
  animation: toast-in .15s ease-out;
}
.dropdown-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.dropdown-head h4 { margin: 0; font-size: 14px; font-weight: 600; }
.dropdown-body { max-height: 380px; overflow-y: auto; }
.dropdown-item {
  padding: 12px 16px;
  border-bottom: 1px solid #F3F4F6;
  display: flex; gap: 10px;
  cursor: pointer;
}
.dropdown-item:hover { background: #FAFBFC; }
.dropdown-item:last-child { border-bottom: 0; }

/* Живой глобальный поиск — выпадающий блок под полем */
.search-dd {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 1200;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
  max-height: 70vh; overflow-y: auto; padding: 6px;
}
.search-dd .search-dd-head {
  font-weight: 600; font-size: 11px; color: #6B7280; text-transform: uppercase;
  letter-spacing: .5px; margin: 8px 8px 4px;
}
.search-dd .search-dd-item { padding: 9px 10px; border: 0; border-radius: 8px; }
.search-dd .search-dd-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }

/* История КП в карточке сделки */
.kp-row { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: #fff; }
.kp-info { min-width: 0; flex: 1; overflow: hidden; }
.kp-info > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kp-actions { display: flex; gap: 4px; flex: none; }
.kp-act { width: 28px; height: 28px; border: 1px solid var(--border); background: #fff; border-radius: 6px;
  cursor: pointer; font-size: 13px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.kp-act:hover { background: #F1F5F9; }
.kp-act.kp-fav { color: #F59E0B; border-color: #F59E0B; }
.kp-act.kp-del:hover { background: #EF4444; color: #fff; border-color: #EF4444; }

/* Вкладка «Товары» — единый минималистичный вид: аккуратные карточки, компактно */
.chat-items { padding: 14px; }
.chat-items .items-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.chat-items .items-card:last-child { margin-bottom: 0; }
.chat-items .items-card > .section-title { margin: 0 0 10px; }
/* Шапка карточки: заголовок слева, компактная кнопка справа */
.chat-items .items-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chat-items .items-card-head .section-title { margin: 0; }
.chat-items .items-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
/* Индикатор авто-сохранения позиций */
.items-save-status { font-size: 12px; font-weight: 500; white-space: nowrap; transition: opacity .15s ease, color .15s ease; }
.items-save-status.is-saving { color: var(--muted); }
.items-save-status.is-saved { color: #10B981; }
.items-save-status.is-error { color: #EF4444; }
.chat-items .items-total-row { display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 12px; padding-top: 10px; border-top: 1px solid #F1F3F5; }
.chat-items .items-total-row .lbl { font-size: 13px; color: var(--muted); }
.chat-items .items-total-row .val { font-size: 16px; font-weight: 700; }
.chat-items .kp-desc { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 12px; }
.chat-items .kp-list { margin-top: 12px; }
/* строки КП внутри карточки — без вложенных рамок, мягкий фон */
.chat-items .kp-list .kp-row { border: 0; background: #F8FAFC; padding: 8px 10px; }
.chat-items .kp-list .kp-act { background: #fff; }
/* Компактная таблица позиций */
.chat-items .line-items-table td { padding: 5px 6px; }
.chat-items .line-items-table th { padding: 3px 6px; }
.dropdown-item .di-icon { font-size: 18px; flex-shrink: 0; }
.dropdown-item .di-body { flex: 1; font-size: 13px; line-height: 1.35; }
.dropdown-item .di-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.backdrop-click {
  position: fixed; inset: 0;
  z-index: 140;
}

/* ---------- About / stub modal ---------- */
.stub-body {
  text-align: center;
  padding: 8px 0 4px;
}
.stub-body .stub-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}
.stub-body p { color: var(--muted); line-height: 1.5; margin: 4px 0; }
.stub-body .stub-list {
  text-align: left;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-2);
}
.stub-body .stub-list li { margin: 4px 0; }

/* ---------- Selectable / hover for rows ---------- */
table.data tbody tr.active-row { background: var(--brand-soft); }
.cat-tile.active { border-color: var(--brand); background: var(--brand-soft); }

/* Drag handle hint for kanban (visual only) */
.k-card:active { cursor: grabbing; }
.k-card.dragging { opacity: .4; transform: scale(.98); }
.k-col.drag-over { background: var(--brand-soft); }
.k-col.drag-over .k-col-body { background: rgba(0, 166, 226, .04); }

/* Перетаскивание этапов (порядок столбцов) — клон следует за курсором */
.k-col-head .stage-grip { cursor: grab; opacity: .4; font-size: 13px; line-height: 1; padding: 0 1px; user-select: none; flex: none; touch-action: none; }
.k-col-head .stage-grip:hover { opacity: .85; }
.k-col-head .stage-grip:active { cursor: grabbing; }
.k-col-ghost { position: fixed; z-index: 1000; pointer-events: none; margin: 0;
  box-shadow: 0 14px 34px rgba(17,20,24,.24); opacity: .96; transform: rotate(1.5deg);
  max-height: 70vh; overflow: hidden; }
.k-col-placeholder { opacity: .35; }
.k-col-placeholder * { visibility: hidden; }
body.dragging-stage { user-select: none; cursor: grabbing; }

/* ---------- Login screen ---------- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0F1620 0%, #1A2332 50%, #0F1620 100%);
  padding: 40px 20px;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 40px 44px 32px;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 80px rgba(0,0,0,.4);
}
.login-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.login-brand .logo-text b { font-size: 20px; display: block; }
.login-brand .logo-text span { font-size: 13px; color: var(--muted); }
.login-card h2 {
  margin: 0 0 4px;
  font-size: 22px; font-weight: 700;
}
.login-card .login-sub {
  margin: 0 0 22px;
  color: var(--muted); font-size: 13px;
}
.login-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.login-form label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: block; }
.login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  outline: none;
  font-family: inherit;
}
.login-form input:focus { border-color: var(--brand); }
.login-form .btn { padding: 12px 16px; font-size: 14px; justify-content: center; }
.login-err {
  font-size: 12px; color: var(--red);
  background: var(--red-soft);
  padding: 8px 12px; border-radius: var(--radius-sm);
  display: none;
}
.login-err.show { display: block; }

.demo-divider {
  text-align: center;
  font-size: 11px; color: var(--muted-2);
  text-transform: uppercase; letter-spacing: .8px;
  margin: 18px 0 12px;
  position: relative;
}
.demo-divider::before, .demo-divider::after {
  content: ''; position: absolute; top: 50%;
  width: 30%; height: 1px; background: var(--border);
}
.demo-divider::before { left: 0; }
.demo-divider::after  { right: 0; }

.demo-accounts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.demo-accounts.big {
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.demo-acc {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  text-align: left;
  font-family: inherit;
}
.demo-acc:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.demo-acc.big {
  padding: 14px 18px;
  border-width: 2px;
  border-radius: var(--radius);
}
.demo-acc.big:hover {
  background: var(--brand-soft);
}
.demo-acc .avatar { width: 32px; height: 32px; font-size: 11px; flex-shrink: 0; }
.demo-acc.big .avatar { width: 44px; height: 44px; font-size: 14px; }
.demo-acc .demo-body { line-height: 1.25; flex: 1; }
.demo-acc .demo-name { font-size: 13px; font-weight: 600; }
.demo-acc.big .demo-name { font-size: 15px; font-weight: 700; }
.demo-acc .demo-role { font-size: 11px; color: var(--muted); }
.demo-acc.big .demo-role { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.demo-acc .demo-hint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.demo-acc .demo-arrow {
  font-size: 20px; color: var(--muted-2);
  transition: transform .15s, color .15s;
}
.demo-acc.big:hover .demo-arrow {
  color: var(--brand);
  transform: translateX(4px);
}

.manual-login {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 8px;
}
.manual-login summary {
  cursor: pointer;
  font-size: 13px; color: var(--muted);
  user-select: none;
  list-style: none;
  text-align: center;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: background .15s;
}
.manual-login summary::-webkit-details-marker { display: none; }
.manual-login summary:hover { background: var(--bg); color: var(--ink); }
.manual-login summary::before { content: '▸ '; }
.manual-login[open] summary::before { content: '▾ '; }
.manual-login code {
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
  color: var(--brand-dark);
}

.login-foot {
  margin-top: 22px;
  text-align: center;
  font-size: 11px; color: var(--muted-2);
}

/* ---------- Locked module placeholder ---------- */
.no-access {
  display: flex; align-items: center; justify-content: center;
  min-height: 50vh;
  flex-direction: column; gap: 10px;
  color: var(--muted);
}
.no-access .lock-icon { font-size: 48px; opacity: .4; }
.no-access h2 { margin: 0; font-size: 18px; color: var(--ink); }

/* ---------- Line items in deal ---------- */
.line-items {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 8px;
}
.line-items table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.line-items th {
  background: #FAFBFC;
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.line-items td {
  padding: 8px 10px;
  border-bottom: 1px solid #F3F4F6;
  vertical-align: middle;
}
.line-items td.num { text-align: right; font-variant-numeric: tabular-nums; }
.line-items input.qty {
  width: 60px; padding: 4px 6px;
  border: 1px solid var(--border); border-radius: 4px;
  text-align: right; font-size: 12px;
  font-family: inherit;
}
.line-items input.qty:focus { border-color: var(--brand); outline: none; }
.line-items .x-btn {
  background: transparent; border: 0; color: var(--muted-2);
  cursor: pointer; font-size: 16px; padding: 0 4px;
}
.line-items .x-btn:hover { color: var(--red); }
.line-items tfoot td {
  padding: 10px 12px;
  font-weight: 700;
  background: #FAFBFC;
  border-top: 1px solid var(--border);
}
.line-items .empty-row td {
  padding: 20px; text-align: center; color: var(--muted); font-size: 12px;
}
.product-picker {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 8px;
}
.product-picker .pp-item {
  padding: 8px 12px;
  border-bottom: 1px solid #F3F4F6;
  cursor: pointer;
  font-size: 12.5px;
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.product-picker .pp-item:hover { background: var(--brand-soft); }
.product-picker .pp-item .pp-sku { color: var(--muted); font-family: monospace; font-size: 11px; }
.product-picker .pp-item .pp-price { font-weight: 600; }

/* Встроенный подбор товара во вкладке «Товары» (вместо кнопки/модалки) */
.pp-host { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }
.pp-host .pp-title { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 8px; }
.pp-search { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; box-sizing: border-box; }
.pp-search:focus { border-color: var(--brand); }
.product-picker.pp-inline { max-height: 300px; }

/* ---------- Print invoice ---------- */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; padding: 30px; background: #fff; }
}
.print-area {
  font-family: 'Inter', sans-serif;
  background: #fff;
  padding: 40px;
  max-width: 720px;
  margin: 0 auto;
  font-size: 13px;
  color: #111;
}
.print-area .pr-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 14px; margin-bottom: 20px;
}
.print-area .pr-head .pr-logo { display: flex; align-items: center; gap: 12px; }
.print-area .pr-head h2 { margin: 0; font-size: 20px; }
.print-area .pr-head .pr-meta { text-align: right; font-size: 12px; color: #555; line-height: 1.5; }
.print-area .pr-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-bottom: 20px; }
.print-area .pr-parties .party-title { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.print-area .pr-parties .party-name { font-weight: 700; margin-bottom: 4px; }
.print-area .pr-parties .party-line { font-size: 12px; color: #555; }
.print-area table.pr-table {
  width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 12px;
}
.print-area table.pr-table th {
  background: #F4F5F7;
  padding: 8px 10px;
  text-align: left;
  font-weight: 700;
  border: 1px solid #E5E7EB;
}
.print-area table.pr-table td {
  padding: 8px 10px;
  border: 1px solid #E5E7EB;
}
.print-area table.pr-table .num { text-align: right; }
.print-area .pr-totals { text-align: right; margin: 14px 0; font-size: 13px; }
.print-area .pr-totals .total-line { display: flex; justify-content: flex-end; gap: 24px; padding: 3px 0; }
.print-area .pr-totals .total-line.grand { font-weight: 700; font-size: 16px; border-top: 2px solid #111; padding-top: 8px; margin-top: 8px; }
.print-area .pr-foot { margin-top: 30px; padding-top: 16px; border-top: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: flex-end; font-size: 11px; color: #888; }
.print-area .pr-stamp {
  border: 2px dashed #ccc;
  border-radius: 50%;
  width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 9px; color: #aaa;
  transform: rotate(-8deg);
}

.print-controls {
  position: fixed; top: 16px; right: 16px;
  display: flex; gap: 8px; z-index: 101;
}
@media print { .print-controls { display: none !important; } }

/* ============================================================
   АДАПТИВ (мобильный / планшет)
   ============================================================ */
.menu-toggle {
  display: none;
  background: transparent; border: 0; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink); padding: 4px 8px;
}
.nav-backdrop { display: none; }

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-h) 1fr;
    grid-template-areas: "header" "main";
  }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 264px; max-width: 84vw;
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 70;
  }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 50px rgba(0,0,0,.5); }
  body.nav-open .nav-backdrop {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.45); z-index: 65;
  }

  .menu-toggle { display: inline-flex; align-items: center; }
  .header { padding: 0 12px; gap: 10px; }
  .header-search { display: none; }
  .header-title { font-size: 15px; }
  .user-chip .name, .user-chip .role { display: none; }

  .main { padding: 16px 14px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-head .actions { flex-wrap: wrap; }

  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }

  .table-toolbar { flex-wrap: wrap; }
  .table-toolbar input, .table-toolbar select { min-width: 0; flex: 1 1 140px; }
  .table-wrap { overflow-x: auto; }

  .kanban { overflow-x: auto; }
  .kanban .k-col { flex: 0 0 82vw; min-width: 82vw; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .modal { width: 96vw; max-width: 96vw; max-height: 92vh; }
  .modal-body { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }

  /* 16px у полей ввода — чтобы iOS не зумил страницу при фокусе */
  .form-row input, .form-row select, .form-row textarea,
  .header-search input, .chat-input input { font-size: 16px; }

  /* кнопки в подвале модалок — удобный тап, перенос по ширине */
  .modal-foot { padding: 12px 16px; }
  .modal-foot button { flex: 1 1 auto; min-height: 40px; }

  /* действия в заголовке страницы тянутся на всю ширину */
  .page-head .actions { width: 100%; }
  .page-head .actions > * { flex: 1 1 auto; }

  /* (вкладки карточки сделки настраиваются ниже — перенос строк, чтобы все были видны) */
}

@media (max-width: 480px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-head h1 { font-size: 19px; }
  .main { padding: 14px 12px; }
  .card { padding: 14px; }
  .modal-head { padding: 14px 16px; }
  .kanban .k-col { flex: 0 0 88vw; min-width: 88vw; }
  /* в подвале модалки кнопки — в столбик на узких экранах */
  .modal-foot button { flex: 1 1 100%; }
}

/* ============================================================
   SIP CLIENT — браузерный софтфон (WebRTC): нижний бар + оверлей-диалер
   ============================================================ */
#sip-ui { position: fixed; z-index: 9000; }
.sip-bar {
  position: fixed; right: 16px; bottom: 16px; z-index: 9000;
  display: flex; align-items: center; gap: 8px;
  background: #111827; color: #fff; border-radius: 999px;
  padding: 8px 14px; font-size: 13px; box-shadow: 0 8px 30px rgba(0,0,0,.35);
  cursor: pointer; user-select: none;
}
.sip-bar-dot { width: 9px; height: 9px; border-radius: 50%; background: #9CA3AF; flex: none; }
.sip-bar-ready .sip-bar-dot { background: #22C55E; }
.sip-bar-connecting .sip-bar-dot { background: #F59E0B; animation: sipPulse 1s infinite; }
.sip-bar-calling .sip-bar-dot, .sip-bar-ringing .sip-bar-dot { background: #3B82F6; animation: sipPulse .7s infinite; }
.sip-bar-in-call .sip-bar-dot { background: #22C55E; }
@keyframes sipPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.sip-bar-timer { font-variant-numeric: tabular-nums; opacity: .85; }
.sip-bar-hangup { background: #EF4444; color: #fff; border: 0; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; line-height: 1; }

.sip-overlay {
  position: fixed; inset: 0; z-index: 9001;
  display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,.5);
}
.sip-overlay-card {
  background: #fff; border-radius: 18px; padding: 28px 24px; width: 300px; max-width: 92vw;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.4);
}
.sip-overlay-state { font-size: 13px; color: #6B7280; margin-bottom: 8px; }
.sip-overlay-name { font-size: 19px; font-weight: 700; }
.sip-overlay-phone { font-size: 14px; color: #6B7280; margin-top: 2px; font-variant-numeric: tabular-nums; }
.sip-overlay-timer { font-size: 22px; font-weight: 700; margin-top: 10px; font-variant-numeric: tabular-nums; }
.sip-overlay-actions { display: flex; justify-content: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.sip-btn {
  width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--border, #E5E7EB);
  background: #F3F4F6; cursor: pointer; font-size: 20px; display: inline-flex; align-items: center; justify-content: center;
}
.sip-btn:hover { background: #E5E7EB; }
.sip-btn-active { background: var(--brand, #00A6E2); color: #fff; border-color: var(--brand, #00A6E2); }
.sip-btn-hangup-overlay { background: #EF4444; color: #fff; border-color: #EF4444; }
.sip-btn-answer { background: #22C55E; color: #fff; border-color: #22C55E; }
.sip-dtmf-pad { margin-top: 14px; }
.sip-dtmf-display-row { display: flex; gap: 6px; margin-bottom: 8px; }
.sip-dtmf-display { flex: 1; min-height: 30px; border: 1px solid var(--border, #E5E7EB); border-radius: 8px; padding: 5px 8px; font-size: 18px; letter-spacing: 2px; }
.sip-dtmf-clear { border: 1px solid var(--border, #E5E7EB); background: #F3F4F6; border-radius: 8px; width: 36px; cursor: pointer; }
.sip-dtmf-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sip-dtmf-key { padding: 12px 0; border: 1px solid var(--border, #E5E7EB); background: #fff; border-radius: 10px; font-size: 18px; cursor: pointer; }
.sip-dtmf-key:hover { background: #F3F4F6; }
@media (max-width: 480px) {
  .sip-bar { left: 12px; right: 12px; bottom: 12px; justify-content: center; }
}
