/* Aminamed CRM — фирменный стиль (custom build by Pllato).
   Палитра бренда: medical green #1F9C4D + lime #95C944 + dark #0F1419.
   Тёмная тема — по умолчанию. Светлая — через [data-theme="light"]. */

:root {
  /* Brand (общие для обеих тем) */
  --brand-navy: #0F1419;       /* now: deep medical dark (charcoal) */
  --brand-bronze: #1F9C4D;     /* now: aminamed green */
  --brand-bronze-soft: #25B25A;/* now: brighter green for hover */

  --radius: 10px;
  --radius-sm: 6px;
}

/* ----- Dark theme (default) ----- */
:root,
[data-theme="dark"] {
  --bg: #0F1419;
  --surface: #1A1F26;
  --surface-2: #2B323C;
  --surface-hover: #374152;
  --border: #3A4452;
  --border-soft: #2F3845;

  --text: #F1F5F2;
  --text-muted: #9CA8B8;
  --text-dim: #6B7480;

  --accent: var(--brand-bronze);
  --accent-hover: var(--brand-bronze-soft);
  --accent-tint: rgba(31, 156, 77, .12);
  --accent-tint-strong: rgba(31, 156, 77, .2);

  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;

  --shadow: 0 4px 12px rgba(0, 0, 0, .25), 0 1px 3px rgba(0, 0, 0, .15);
}

/* ----- Light theme ----- */
[data-theme="light"] {
  --bg: #F7F9F7;             /* cool medical off-white */
  --surface: #ffffff;
  --surface-2: #ECF7EF;
  --surface-hover: #D9EDDE;
  --border: #D4E0D7;
  --border-soft: #E2EBE5;

  --text: #111418;
  --text-muted: #5A6470;
  --text-dim: #97A0AC;

  --accent: #157A3B;         /* deeper green for contrast on light */
  --accent-hover: #1F9C4D;
  --accent-tint: rgba(31, 156, 77, .1);
  --accent-tint-strong: rgba(31, 156, 77, .18);

  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;

  --shadow: 0 1px 3px rgba(10, 22, 40, .08), 0 1px 2px rgba(10, 22, 40, .04);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- Boot ---------- */
.boot {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-muted);
}
.boot-logo {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  animation: pulse 1.6s ease-in-out infinite;
}
.boot-text { font-size: 13px; letter-spacing: 0.02em; }
@keyframes pulse {
  0%, 100% { opacity: .6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* ---------- Login screen ---------- */
.login-wrap {
  margin: auto;
  width: 100%;
  max-width: 400px;
  padding: 32px 24px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.login-brand img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.login-brand h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-brand .tagline {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-card .sub {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.55;
}
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface-2);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: var(--text-dim); }
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.btn {
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.login-msg {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.login-msg.err { color: var(--danger); }

.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.google-btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.google-btn svg { flex-shrink: 0; }

.login-footer-hint {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--text-dim);
  text-align: center;
  line-height: 1.5;
}

/* ---------- App shell ---------- */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "side topbar"
    "side main";
  min-height: 100vh;
}
.sidebar {
  grid-area: side;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand-title .name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-title .sub {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}
.nav-section {
  margin-top: 14px;
  padding: 0 8px 6px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.nav-item.active .nav-ico { color: var(--accent); }
.nav-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-item { position: relative; }
.nav-ico {
  width: 18px; height: 18px;
  flex-shrink: 0;
  display: inline-grid;
  place-items: center;
  color: var(--text-dim);
}
.nav-ico svg { width: 18px; height: 18px; stroke-width: 1.75; }
.nav-spacer { flex: 1; }

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.topbar .user {
  margin-left: auto;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.theme-toggle {
  margin-left: auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  position: relative;
}
.theme-toggle:hover { background: var(--surface-hover); color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 16px; height: 16px; stroke-width: 1.75; }
.theme-toggle + .user, .theme-toggle + .theme-toggle { margin-left: 0; }
.notif-btn { margin-left: 0; }
.notif-dot {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  background: var(--danger);
  color: white;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  display: grid;
  place-items: center;
  border: 1.5px solid var(--surface);
}
.topbar { position: relative; }
.notif-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 20px;
  width: 380px;
  max-height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 90;
  animation: slideUp .15s ease-out;
}
.notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.notif-head h3 { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.notif-head .btn-ghost { padding: 5px 10px; font-size: 11.5px; }
.notif-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.notif-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  text-decoration: none;
  color: var(--text);
  transition: background .12s;
  position: relative;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread::before {
  content: "";
  position: absolute;
  left: 6px; top: 50%;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  transform: translateY(-50%);
}
.notif-icon {
  width: 32px; height: 32px;
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  border-radius: 8px;
  font-size: 15px;
  flex-shrink: 0;
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 13px; line-height: 1.35; }
.notif-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.notif-meta { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--brand-navy);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12px;
}

.main {
  grid-area: main;
  padding: 24px;
  overflow: auto;
}
.placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 24px;
  text-align: center;
  color: var(--text-muted);
}
.placeholder-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  border-radius: 12px;
  color: var(--accent);
}
.placeholder-icon svg { width: 22px; height: 22px; stroke-width: 1.75; }
.placeholder h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.placeholder p { margin: 0; font-size: 13px; line-height: 1.55; }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--accent-tint);
  color: var(--accent-hover);
  margin-left: 8px;
  vertical-align: middle;
}
.badge.warn { background: rgba(245, 158, 11, .15); color: #fbbf24; }

/* ---------- Контакты ---------- */
.contacts-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(380px, 1fr) minmax(340px, 460px);
  gap: 16px;
  height: calc(100vh - 56px - 48px);
  margin: -24px;
  padding: 24px;
  align-items: stretch;
}

.contacts-list-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.contacts-detail-pane {
  overflow: auto;
  min-width: 0;
}
.contacts-chat-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
  display: flex;
}
.contact-chat-card {
  width: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.contact-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.contact-chat-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.contact-chat-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.contact-chat-messages {
  padding: 14px 16px;
}
.contact-chat-card .detail-empty {
  margin: auto;
  padding: 24px 18px;
}
.contact-chat-card .detail-empty h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.contact-chat-card .detail-empty p {
  margin: 0;
}

.list-toolbar {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
}
.search-input {
  flex: 1;
  position: relative;
}
.search-input .search-ico {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  width: 16px; height: 16px;
  display: grid; place-items: center;
}
.search-input .search-ico svg { width: 16px; height: 16px; stroke-width: 1.75; }
.search-input input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.search-input input::placeholder { color: var(--text-dim); }
.search-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn-primary {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--brand-navy);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary svg { width: 14px; height: 14px; stroke-width: 2.25; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--accent); }
.btn-ghost svg { width: 14px; height: 14px; stroke-width: 1.75; }
.btn-ghost.danger:hover { color: var(--danger); border-color: var(--danger); }

.list-meta {
  padding: 8px 14px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.dupes-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, .35);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
}
.dupes-badge svg { width: 12px; height: 12px; stroke-width: 1.75; }
/* Импорт контактов */
.import-body { padding: 20px 22px; overflow-y: auto; }
.import-step1, .import-step2, .import-step3 { display: flex; flex-direction: column; gap: 12px; }
.import-drop {
  padding: 30px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color .15s, background .15s;
}
.import-drop.over { border-color: var(--accent); background: var(--accent-tint); color: var(--text); }
.import-step1 textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-family: 'SF Mono', Menlo, monospace;
  resize: vertical;
  min-height: 100px;
}
.import-step1 textarea:focus { outline: none; border-color: var(--accent); }
.import-summary { font-size: 14px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); }
.import-options { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.import-stage-pick {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  margin-left: 28px;
}
.import-stage-pick select {
  min-width: 220px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.import-map-table-wrap,
.import-preview-table-wrap {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 360px;
  background: var(--surface);
}
.import-map-table,
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.import-map-table th,
.import-map-table td,
.import-preview-table th,
.import-preview-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}
.import-map-table thead th,
.import-preview-table thead th {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.import-preview-table tr.dupe td {
  background: rgba(245, 158, 11, .08);
}
.import-map-table select {
  min-width: 240px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.import-inline-field {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
  background: var(--surface-2);
}
.import-inline-field h4 {
  margin: 0 0 8px;
  font-size: 13px;
}
.import-inline-field-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.import-inline-field-row input,
.import-inline-field-row select {
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.import-hint-warn {
  font-size: 12px;
  color: var(--warning);
}
.import-list {
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px;
}
.import-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 4px;
  background: var(--surface-2);
  font-size: 13px;
}
.import-row.dupe { opacity: 0.55; background: rgba(245, 158, 11, .08); }
.import-i { color: var(--text-dim); font-size: 11px; width: 24px; text-align: right; }
.import-cell { flex: 1; min-width: 0; }
.import-name { font-weight: 500; }
.import-sub { font-size: 12px; color: var(--text-muted); }
.import-badge {
  padding: 2px 7px;
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.import-more { text-align: center; padding: 8px; color: var(--text-dim); font-size: 12px; }

.dupes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 22px;
  overflow-y: auto;
}
.dupe-pair {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.dupe-reason {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.dupe-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.dupe-card {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.dupe-card:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); }
.dupe-card input { margin-top: 2px; accent-color: var(--accent); }
.dupe-name { font-weight: 600; font-size: 13.5px; }
.dupe-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.dupe-merge-btn { width: auto; padding: 7px 14px; }

.chip-mini-accent { background: var(--accent-tint) !important; color: var(--accent-hover) !important; }

.related-deals { display: flex; flex-direction: column; gap: 4px; }
.related-deal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  transition: border-color .12s;
}
.related-deal:hover { border-color: var(--accent); }
.related-deal-title { flex: 1; }
.related-deal-amount { color: var(--accent); font-weight: 600; font-size: 12.5px; }
.contacts-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: background .12s;
  margin-bottom: 2px;
}
.contact-row:hover { background: var(--surface-hover); }
.contact-row.active { background: var(--accent-tint); }
.contact-row.active .contact-row-name { color: var(--accent-hover); }

.avatar {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--brand-navy);
  display: grid; place-items: center;
  font-weight: 700;
  border-radius: 50%;
}
.avatar-sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-md { width: 40px; height: 40px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.group { background: var(--text-muted); color: var(--brand-navy); }

.contact-row-body { flex: 1; min-width: 0; }
.contact-row-name {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-row-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-row-tags { margin-top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.chip-mini {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.contact-row.active .chip-mini { background: rgba(255, 255, 255, .05); }

.list-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.5;
}
.list-empty-ico {
  width: 36px; height: 36px;
  margin: 0 auto 12px;
  background: var(--accent-tint);
  border-radius: 10px;
  display: grid; place-items: center;
  color: var(--accent);
}
.list-empty-ico svg { width: 18px; height: 18px; stroke-width: 1.75; }

/* ----- Detail card ----- */
.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 720px;
}
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.detail-title { flex: 1; min-width: 0; }
.detail-title h2 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: break-word;
}
.detail-sub {
  color: var(--text-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-ghost.icon-only { padding: 7px; }
.btn-ghost.icon-only svg { width: 16px; height: 16px; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px 24px;
  padding: 16px 0;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}
.detail-row > div { min-width: 0; flex: 1; }
.detail-row-value { overflow-wrap: anywhere; }
.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 13px;
}
.detail-row-ico {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.detail-row-ico svg { width: 15px; height: 15px; stroke-width: 1.75; }
.detail-row-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
}
.detail-row-value { color: var(--text); font-weight: 500; }
.detail-row-value a { color: var(--accent); text-decoration: none; }
.detail-row-value a:hover { text-decoration: underline; }

.detail-section { margin-top: 18px; }
.detail-section-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-hover);
  font-size: 11.5px;
  font-weight: 600;
}
.notes {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.detail-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-dim);
}

.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.detail-empty-ico {
  width: 56px; height: 56px;
  background: var(--accent-tint);
  border-radius: 14px;
  display: grid; place-items: center;
  color: var(--accent);
  margin-bottom: 14px;
}
.detail-empty-ico svg { width: 26px; height: 26px; stroke-width: 1.75; }
.detail-empty h3 {
  margin: 0 0 6px;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
}
.detail-empty p { margin: 0; font-size: 13px; }

/* ----- Form ----- */
.form-card .form-header {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}
.form-card .form-header h2 {
  margin: 0;
  flex: 1;
  font-size: 18px;
  font-weight: 700;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .field { margin: 0; }
.form-grid .field-wide { grid-column: 1 / -1; }
.form-grid label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 5px;
}
.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
}
.form-grid textarea { resize: vertical; min-height: 80px; }
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.form-footer .btn { width: auto; padding: 9px 22px; }

/* ---------- Сделки (Kanban) ---------- */
.deals-view {
  margin: -24px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px);
  gap: 16px;
}

.deals-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.crm-top-controls {
  flex: 1;
  min-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.crm-view-switch {
  display: inline-flex;
  gap: 8px;
}

.crm-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.crm-view-btn svg {
  width: 15px;
  height: 15px;
}

.crm-view-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}

.crm-global-search {
  position: relative;
  display: flex;
  align-items: center;
}

.crm-search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
}

.crm-search-icon svg {
  width: 16px;
  height: 16px;
}

#crmGlobalSearch {
  width: 100%;
  padding: 10px 40px 10px 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

#crmGlobalSearch:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.crm-search-clear {
  position: absolute;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-search-clear:hover {
  color: var(--text);
  background: var(--surface-2);
}

.crm-search-clear svg {
  width: 14px;
  height: 14px;
}

.crm-search-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -2px;
}

.crm-search-empty {
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--text-dim);
  background: var(--surface);
}

.crm-calls-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

#crmCallsMount {
  min-height: 100%;
}

#crmCallsMount .calls-page {
  padding: 16px;
}

.deals-toolbar-right {
  display: flex;
  gap: 8px;
}
.deals-totals {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex: 1;
}
.stage-total {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.stage-total .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--stage-color);
  flex-shrink: 0;
}
.stage-total .stage-name {
  color: var(--text-muted);
  font-weight: 500;
}
.stage-total .stage-count {
  color: var(--text);
  font-weight: 700;
  padding: 1px 7px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 11px;
}
.stage-total .stage-sum {
  color: var(--text);
  font-weight: 600;
}

.kanban {
  display: flex;
  gap: 12px;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 8px;
}
.kanban-col {
  flex: 1 0 240px;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color .15s, background .15s;
}
.kanban-col.drop-target {
  border-color: var(--stage-color, var(--accent));
  background: var(--surface-hover);
}
.kanban-col-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  border-top: 3px solid var(--stage-color);
}
.kanban-col-head .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--stage-color);
  flex-shrink: 0;
}
.kanban-col-title {
  flex: 1;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.kanban-col-count {
  padding: 2px 8px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
}
.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
}

.deal-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: grab;
  transition: border-color .12s, background .12s, transform .05s;
}
.deal-card:hover {
  border-color: var(--accent);
}
.deal-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 8px;
  margin-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.deal-card:active { cursor: grabbing; }
.deal-card.dragging {
  opacity: 0.4;
  transform: rotate(-1deg);
}
.deal-card-title {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 8px;
  line-height: 1.35;
}
.deal-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.deal-amount {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}
.deal-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
}
.deal-due svg { width: 12px; height: 12px; stroke-width: 1.75; }
.deal-contact {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}

.avatar-xs { width: 22px; height: 22px; font-size: 9px; }

/* ----- Modal ----- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, .65);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
  padding: 24px;
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease-out;
}
.modal-xl { max-width: 1100px; }
.modal-actions { display: flex; gap: 4px; align-items: center; }
.deal-head-main { min-width: 0; }
.deal-meta-line {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

/* ----- Шкала стадий в карточке сделки ----- */
.deal-stage-bar {
  display: flex;
  gap: 0;
  padding: 12px 22px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
}
.deal-stage-step {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1 1 120px;
  min-width: 120px;
}
.deal-stage-bar-btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 6px;
  border: 1px solid var(--border-soft);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.deal-stage-bar-btn:hover {
  border-color: var(--stage-color);
  color: var(--stage-color);
}
.deal-stage-bar-btn.active {
  background: var(--stage-color);
  color: white;
  border-color: var(--stage-color);
}
.deal-stage-step.is-win .deal-stage-bar-btn.active {
  background: #14804a;
  border-color: #14804a;
}
.deal-stage-step.is-loss .deal-stage-bar-btn.active {
  background: #7f8898;
  border-color: #7f8898;
}
.deal-stage-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.deal-stage-arrow svg {
  width: 14px;
  height: 14px;
  stroke-width: 1.8;
}

/* ----- Split-view карточки сделки ----- */
.deal-modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.deal-form-col {
  padding: 18px 22px;
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
}
.deal-timeline-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
}
.form-grid-1col { grid-template-columns: 1fr !important; }
.form-grid-1col .field-wide { grid-column: 1 / -1; }
.form-buttons {
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.form-buttons .btn { width: auto; padding: 9px 22px; }
.deal-autosave-hint {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 6px 10px;
}
.deal-autosave-hint[data-state="saving"] {
  color: var(--text);
  border-color: var(--accent);
}
.deal-autosave-hint[data-state="saved"] {
  color: #14804a;
  border-color: rgba(20, 128, 74, 0.28);
}
.deal-autosave-hint[data-state="error"] {
  color: #b42318;
  border-color: rgba(180, 35, 24, 0.28);
}

/* ----- Таймлайн в сделке ----- */
.timeline-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  flex-shrink: 0;
}
.tlb-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.tlb-btn:hover { color: var(--text); border-color: var(--accent); }
.tlb-btn.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
  border-color: var(--accent);
}
.timeline-input {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.timeline-input input, .timeline-input textarea, .timeline-input select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.timeline-input input:focus, .timeline-input textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.timeline-input .btn-primary { align-self: flex-end; padding: 7px 14px; }
.timeline-filters {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}
.timeline-filter-btn {
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-dim);
  padding: 9px 10px 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.timeline-filter-btn:hover { color: var(--text); }
.timeline-filter-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}
.timeline-filter-count {
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 0.03em;
}
.timeline-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tl-empty {
  color: var(--text-dim);
  font-size: 12.5px;
  text-align: center;
  padding: 24px 12px;
}
.tl-item {
  display: flex;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.tl-ico {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent-tint);
  border-radius: 8px;
  font-size: 14px;
  flex-shrink: 0;
}
.tl-body { flex: 1; min-width: 0; font-size: 13px; line-height: 1.45; }
.tl-head {
  display: flex;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 4px;
  font-size: 11.5px;
  flex-wrap: wrap;
}
.tl-author { font-weight: 600; color: var(--text); }
.tl-type {
  padding: 1px 7px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
}
.tl-time { color: var(--text-dim); font-size: 11px; margin-left: auto; }
.act-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 3px; }
.act-task { display: flex; gap: 10px; align-items: center; }
.act-task-title { font-weight: 600; }
.act-task-due { color: var(--accent); font-size: 12px; }
.tl-stage-event {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 0;
  font-size: 11.5px;
  color: var(--text-dim);
}
.tl-stage-mark {
  width: 14px;
  color: var(--text-muted);
  text-align: center;
}

.deal-chat-pane {
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 280px;
  max-height: 46%;
}
.deal-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.deal-chat-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}
.deal-chat-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.deal-chat-messages {
  padding: 12px 14px;
}
.deal-chat-pane .chat-compose {
  padding: 10px 14px;
}
.deal-chat-pane .chat-compose-media {
  padding: 0 14px 10px;
}

/* ----- Редактор стадий ----- */
.stages-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 22px;
  overflow-y: auto;
}
.stage-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.stage-edit-row .se-handle {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  cursor: grab;
}
.stage-edit-row .se-handle svg { width: 14px; height: 14px; }
.stage-edit-row input[type="color"] {
  width: 36px; height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.stage-edit-row input[type="text"] {
  flex: 1;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.stage-edit-row input[type="text"]:focus { outline: none; border-color: var(--accent); }
.stages-up-down {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ud-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ud-row button {
  width: 22px; height: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
}
.ud-row button:disabled { opacity: 0.3; cursor: not-allowed; }

/* На мобильных layout сделки сворачиваем */
@media (max-width: 760px) {
  .deal-modal-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .deal-form-col { border-right: 0; border-bottom: 1px solid var(--border-soft); max-height: 40vh; }
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-form { display: contents; }
.modal-header {
  display: flex;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
}
.modal-header h2 {
  margin: 0;
  flex: 1;
  font-size: 17px;
  font-weight: 700;
}
.modal-header .form-grid { padding: 22px; }
.modal .form-grid {
  padding: 22px;
  overflow-y: auto;
}
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.modal-footer .btn { width: auto; padding: 9px 22px; }
.modal-footer-right {
  display: flex;
  gap: 10px;
}

/* ---------- Задачи ---------- */
.tasks-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 880px;
}

.tasks-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
}
.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
  flex: 1;
  max-width: 360px;
}
.filter-tab {
  flex: 1;
  padding: 7px 12px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.filter-tab:hover { color: var(--text); }
.filter-tab.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
}

.tasks-groups {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.task-group { }
.task-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0 4px;
}
.task-group-head .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text);
}
.task-group-count {
  padding: 1px 7px;
  background: var(--surface-2);
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
.task-list { display: flex; flex-direction: column; gap: 4px; }

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .12s, background .12s;
}
.task-row:hover { border-color: var(--accent); }
.task-row.done { opacity: 0.55; }
.task-row.done .task-title span:last-child { text-decoration: line-through; color: var(--text-muted); }

.task-check {
  width: 20px; height: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1.5px solid var(--border);
  background: var(--surface-2);
  border-radius: 5px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.task-check:hover { border-color: var(--accent); }
.task-check svg { width: 13px; height: 13px; stroke-width: 2.5; color: var(--success); }
.task-row.done .task-check { background: rgba(34, 197, 94, .15); border-color: var(--success); }

.task-body {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}
.task-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}
.prio-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-desc {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.task-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-muted);
}
.task-due, .task-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-due svg, .task-link svg { width: 12px; height: 12px; stroke-width: 1.75; }

/* ----- Task v2: split-view, подзадачи, комментарии ----- */
.task-modal-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}
.task-form-col {
  padding: 18px 22px;
  overflow-y: auto;
  border-right: 1px solid var(--border-soft);
}
.task-chat-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--surface-2);
}
.task-chat-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
}
.task-chat-head h3 { margin: 0 0 2px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.task-chat-head span { font-size: 11.5px; color: var(--text-dim); }
.task-chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.task-comment {
  display: flex;
  gap: 10px;
}
.task-comment-body {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}
.task-comment-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.task-comment-author { font-weight: 600; font-size: 12.5px; }
.task-comment-time { color: var(--text-dim); font-size: 11px; }
.comment-files {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.task-chat-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border-soft);
}
.task-chat-compose textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  resize: vertical;
  min-height: 50px;
}
.task-chat-compose textarea:focus { outline: none; border-color: var(--accent); }
.task-chat-compose-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.task-chat-compose-actions .btn-primary { padding: 7px 12px; }
.comment-attached { flex: 1; font-size: 11.5px; color: var(--text-muted); }

/* участники-чипы */
.participants-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.participant-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  transition: background .12s, border-color .12s;
}
.participant-chip:hover { border-color: var(--accent); }
.participant-chip.on {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-hover);
}
.participant-chip input { display: none; }

/* файлы */
.files-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.file-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--text-dim); font-size: 11px; }
.file-add-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color .12s, color .12s;
}
.file-add-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-add-btn svg { width: 14px; height: 14px; stroke-width: 1.75; }

/* Подзадачи */
.subtasks-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.subtasks-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.subtasks-head h3 { margin: 0; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.subtasks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.subtask-row {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  align-items: flex-start;
  transition: border-color .12s;
}
.subtask-row:hover { border-color: var(--accent); }
.subtask-row.done { opacity: 0.6; }
.subtask-row.done .subtask-title span:last-child { text-decoration: line-through; color: var(--text-muted); }
.subtask-body { flex: 1; cursor: pointer; min-width: 0; }
.subtask-title { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 500; }
.subtask-meta { font-size: 11.5px; color: var(--text-muted); display: flex; gap: 10px; margin-top: 3px; flex-wrap: wrap; }
.subtask-meta svg { width: 11px; height: 11px; stroke-width: 1.75; vertical-align: -1px; }

.parent-crumb {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
}
.parent-crumb:hover { color: var(--accent); }

@media (max-width: 760px) {
  .task-modal-body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .task-form-col { border-right: 0; border-bottom: 1px solid var(--border-soft); max-height: 50vh; }
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-weight: 500 !important;
}
.checkbox-label input[type="checkbox"] {
  width: 18px; height: 18px;
  accent-color: var(--accent);
}

/* ---------- Лента ---------- */
.feed-view {
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.composer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  gap: 12px;
}
.composer-form { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.composer textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
  min-height: 40px;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.composer-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; align-items: center; }
.composer-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.visibility-picker {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.vis-radio {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  cursor: pointer;
  align-items: flex-start;
}
.vis-radio strong { color: var(--text); }
.vis-radio span { color: var(--text-muted); }
.vis-employees {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.vis-employees.disabled { opacity: 0.4; pointer-events: none; }
.post-files {
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.post-private {
  margin-left: 4px;
  font-size: 11px;
  opacity: 0.7;
}

.feed-list { display: flex; flex-direction: column; gap: 12px; }
.post {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.post-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.post-author-name { font-weight: 600; font-size: 13.5px; }
.post-time { font-size: 11.5px; color: var(--text-dim); }
.post-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  margin-bottom: 12px;
  white-space: pre-wrap;
}
.post-footer {
  display: flex;
  gap: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.post-action {
  background: transparent;
  border: 0;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background .12s, color .12s;
}
.post-action:hover { background: var(--surface-2); color: var(--text); }
.post-action.active { color: var(--danger); }

.comments {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comment { display: flex; gap: 10px; }
.comment-body { flex: 1; background: var(--surface-2); padding: 8px 12px; border-radius: var(--radius-sm); font-size: 13px; }
.comment-author { font-weight: 600; font-size: 12px; margin-bottom: 3px; }
.comment-time { color: var(--text-dim); font-weight: 400; }
.comment-form { display: flex; gap: 10px; align-items: center; }
.comment-form input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.comment-form input:focus { outline: none; border-color: var(--accent); }

/* ---------- Чаты ---------- */
:root,
[data-theme="dark"] {
  --wa-pane: #111b21;
  --wa-head: #202c33;
  --wa-input: #2a3942;
  --wa-canvas: #0b141a;
  --wa-msg-in: #202c33;
  --wa-msg-out: #005c4b;
  --wa-msg-text: #e9edef;
  --wa-muted: #8696a0;
  --wa-list-active: #2a3942;
  --wa-list-hover: #233138;
}
[data-theme="light"] {
  --wa-pane: #f0f2f5;
  --wa-head: #f7f8fa;
  --wa-input: #ffffff;
  --wa-canvas: #efeae2;
  --wa-msg-in: #ffffff;
  --wa-msg-out: #d9fdd3;
  --wa-msg-text: #111b21;
  --wa-muted: #667781;
  --wa-list-active: #e9edef;
  --wa-list-hover: #f4f5f7;
}

.chat-view {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 10px;
  height: calc(100vh - 56px - 48px);
  margin: -24px;
  padding: 24px;
}
.chat-list-pane {
  background: var(--wa-pane);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-list-head {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--wa-head);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--wa-muted);
}
.chat-list { flex: 1; overflow-y: auto; padding: 0; }
.chat-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: transparent;
  cursor: pointer;
  text-align: left;
  color: var(--wa-msg-text);
  transition: background .12s;
}
.chat-row:hover { background: var(--wa-list-hover); }
.chat-row.active { background: var(--wa-list-active); }
.chat-row-body { flex: 1; min-width: 0; }
.chat-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.chat-row-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--wa-msg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row-time { font-size: 10.5px; color: var(--wa-muted); flex-shrink: 0; }
.chat-row-preview {
  font-size: 12px;
  color: var(--wa-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-thread-pane,
.contact-chat-card,
.deal-chat-pane {
  background: var(--wa-pane);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-thread-head,
.contact-chat-head,
.deal-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--wa-head);
}
.wa-dialog-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.wa-dialog-user > div:last-child {
  min-width: 0;
}
.wa-dialog-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.wa-action-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--wa-muted);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.02);
  transition: color .12s, border-color .12s, background .12s;
}
.wa-action-link:hover {
  color: #25d366;
  border-color: rgba(37, 211, 102, 0.55);
  background: rgba(37, 211, 102, 0.1);
}

.chat-thread-name,
.contact-chat-title,
.deal-chat-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--wa-msg-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-thread-sub,
.contact-chat-sub,
.deal-chat-sub {
  font-size: 11.5px;
  color: var(--wa-muted);
  margin-top: 1px;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--wa-canvas);
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 26px 26px, 52px 52px;
  background-position: 0 0, 13px 13px;
}
.contact-chat-messages,
.deal-chat-messages { padding: 14px; }
.chat-empty {
  margin: auto;
  color: var(--wa-muted);
  font-size: 13px;
  text-align: center;
}
.msg {
  display: flex;
  flex-direction: column;
  max-width: min(76%, 640px);
}
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.msg-bubble {
  position: relative;
  padding: 7px 10px;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.4;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.msg.me .msg-bubble {
  background: var(--wa-msg-out);
  color: var(--wa-msg-text);
  border-top-right-radius: 3px;
}
.msg.them .msg-bubble {
  background: var(--wa-msg-in);
  color: var(--wa-msg-text);
  border-top-left-radius: 3px;
}
.msg-time {
  font-size: 10.5px;
  color: var(--wa-muted);
  margin-top: 3px;
  padding: 0 4px;
}
.msg-media-wrap { margin-top: 6px; display: grid; gap: 6px; }
.msg-media-img {
  width: min(260px, 100%);
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  display: block;
}
.msg-media-video {
  width: min(320px, 100%);
  max-height: 280px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #000;
}
.msg-media-wrap audio { width: min(320px, 100%); }
.msg-file-link {
  color: #53bdeb;
  text-decoration: none;
  font-weight: 600;
}
.msg-file-link:hover { text-decoration: underline; }
.msg-media-cap {
  font-size: 12px;
  color: var(--wa-muted);
}

.chat-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  background: var(--wa-head);
}
.chat-compose input {
  flex: 1;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--wa-input);
  color: var(--wa-msg-text);
  font-size: 13.5px;
}
.chat-compose input::placeholder { color: var(--wa-muted); }
.chat-compose input:focus {
  outline: none;
  border-color: rgba(37, 211, 102, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.16);
}
.chat-compose .btn-primary {
  width: 40px;
  height: 40px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
}
.chat-compose .btn-primary:hover { background: #1fb95a; }
.chat-compose .btn-primary svg { width: 16px; height: 16px; }
.chat-compose-media {
  padding: 0 12px 10px;
  display: grid;
  grid-template-columns: 1fr 180px auto;
  align-items: center;
  gap: 8px;
  background: var(--wa-head);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.chat-compose-media input {
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--wa-input);
  color: var(--wa-msg-text);
  padding: 8px 12px;
}
.chat-voice-opt {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--wa-muted);
  white-space: nowrap;
}

.contact-chat-card .detail-empty,
.deal-chat-pane .tl-empty {
  margin: auto;
  color: var(--wa-muted);
}

/* light-mode tweaks for better contrast */
[data-theme="light"] .wa-action-link {
  border-color: rgba(17, 27, 33, 0.12);
  background: rgba(17, 27, 33, 0.02);
}
[data-theme="light"] .chat-row {
  border-bottom-color: rgba(17, 27, 33, 0.06);
}
[data-theme="light"] .msg-bubble {
  box-shadow: 0 1px 0 rgba(17, 27, 33, 0.08);
}
[data-theme="light"] .chat-messages {
  background-image:
    radial-gradient(rgba(17, 27, 33, 0.06) 1px, transparent 1px),
    radial-gradient(rgba(17, 27, 33, 0.04) 1px, transparent 1px);
}

@media (max-width: 980px) {
  .chat-view {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 56px - 48px);
  }
  .chat-list-pane {
    max-height: 260px;
  }
  .chat-compose-media {
    grid-template-columns: 1fr;
  }
  .contacts-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(200px, 34vh) minmax(300px, auto) minmax(260px, auto);
    height: auto;
  }
  .contacts-list-pane {
    max-height: 34vh;
  }
  .contacts-chat-pane {
    min-height: 300px;
  }
  .deal-chat-pane {
    min-height: 240px;
    max-height: none;
  }
}

/* ---------- Звонки ---------- */
.calls-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.calls-tab {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.calls-tab.active {
  color: var(--accent-hover);
  border-color: var(--accent);
  background: var(--accent-tint);
}
.calls-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.calls-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.calls-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
}
.calls-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}
.calls-head-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.calls-head-actions select {
  min-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.calls-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.calls-form .field { display: flex; flex-direction: column; gap: 6px; }
.calls-form .field label { font-size: 12px; color: var(--text-muted); }
.calls-form .field input,
.calls-form .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
.calls-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.calls-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface);
}
.calls-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}
.calls-table th,
.calls-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
}
.calls-table th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.calls-table tr:hover td {
  background: var(--surface-hover);
}
.calls-sub {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 11.5px;
}
.calls-empty {
  padding: 24px 14px;
  color: var(--text-muted);
  text-align: center;
}
.calls-error {
  background: rgba(239, 68, 68, .12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, .4);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.calls-ok {
  background: rgba(34, 197, 94, .12);
  color: #86efac;
  border: 1px solid rgba(34, 197, 94, .4);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.calls-breadcrumb {
  display: inline-block;
  margin-bottom: 6px;
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
}
.calls-funnel {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 10px;
}
.funnel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.funnel-card span {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.funnel-card strong {
  font-size: 20px;
  color: var(--text);
}
.calls-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}
.calls-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.calls-filters select,
.calls-filters input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.calls-assign-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.calls-assign-row select {
  min-width: 220px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

.quick-call-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.quick-call-card.compact {
  padding: 12px;
}
.quick-call-head h4 {
  margin: 0 0 4px;
  font-size: 17px;
}
.quick-call-head p {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}
.quick-call-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
}
.quick-call-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.quick-call-grid input,
.quick-call-grid select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.quick-call-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.quick-call-actions .btn-ghost.disabled {
  pointer-events: none;
  opacity: 0.5;
}
.history-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.queue-layout {
  display: grid;
  grid-template-columns: minmax(260px, 32%) 1fr;
  gap: 12px;
  min-height: calc(100vh - 220px);
}
.queue-left {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.queue-left-head {
  padding: 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
}
.queue-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
}
.queue-row {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 4px;
  cursor: pointer;
}
.queue-row:hover { background: var(--surface-hover); }
.queue-row.active { background: var(--accent-tint); }
.queue-row-name { font-weight: 600; font-size: 13px; }
.queue-row-sub { margin-top: 2px; color: var(--text-muted); font-size: 12px; }

.queue-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 0;
  overflow: hidden;
}
.queue-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  padding: 14px;
}
.queue-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.queue-card-head h3 {
  margin: 0 0 4px;
  font-size: 20px;
}
.queue-card-sub {
  color: var(--text-muted);
  font-size: 13px;
}
.queue-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.call-stepper {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.step-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.step-dot.active {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--brand-navy);
}
.step-dot.terminal { border-style: dashed; }

.stage-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stage-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stage-top h4 {
  margin: 0;
  font-size: 16px;
}
.stage-terminal {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(245, 158, 11, .15);
  color: var(--warning);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stage-goal {
  color: var(--text-muted);
  font-size: 13px;
}
.stage-script {
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
}
.stage-tip {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 12px;
}
.stage-objections {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stage-objections details {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 7px 9px;
}
.stage-objections summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}
.stage-objections details > div {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.45;
}
.stage-transitions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.queue-notes label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.queue-notes textarea {
  width: 100%;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.queue-notes textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.finish-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.finish-card h4 {
  margin: 0 0 10px;
  font-size: 15px;
}
.finish-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 8px;
}
.finish-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: var(--text-muted);
}
.finish-grid select,
.finish-grid input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
}
.finish-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.wa-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.wa-preview h4 {
  margin: 0 0 8px;
  font-size: 14px;
}
.wa-preview textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  margin-bottom: 8px;
}

@media (max-width: 1180px) {
  .calls-funnel { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .calls-filters { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .finish-grid { grid-template-columns: repeat(2, minmax(140px, 1fr)); }
}
@media (max-width: 920px) {
  .queue-layout { grid-template-columns: 1fr; min-height: auto; }
  .queue-left { max-height: 280px; }
  .calls-form { grid-template-columns: 1fr; }
  .quick-call-grid { grid-template-columns: 1fr; }
  .quick-call-actions { justify-content: flex-start; }
  .calls-funnel { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .calls-filters { grid-template-columns: 1fr 1fr; }
  .finish-grid { grid-template-columns: 1fr; }
  .deals-toolbar { align-items: stretch; }
  .crm-top-controls { min-width: 100%; }
  .deals-toolbar-right { width: 100%; justify-content: flex-start; }
  .crm-view-switch { width: 100%; }
  .crm-view-btn { flex: 1; justify-content: center; }
}

/* ---------- Дашборд ---------- */
.dash-view {
  max-width: 1200px;
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}
.widget {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.widget-wide { grid-column: span 2; }
@media (max-width: 760px) { .widget-wide { grid-column: span 1; } }

.widget-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.widget-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.widget-sub {
  font-size: 11px;
  color: var(--text-dim);
}
.widget-empty {
  color: var(--text-dim);
  font-size: 13px;
}
.widget-empty a { color: var(--accent); text-decoration: none; }
.widget-empty a:hover { text-decoration: underline; }

.metric-row {
  display: flex;
  gap: 24px;
  padding: 4px 0 8px;
}
.metric { flex: 1; }
.metric-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.metric-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.metric-value.success { color: var(--success); }
.metric-hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.stage-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.stage-bar-row { font-size: 12px; }
.stage-bar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.stage-bar-head .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.stage-bar-name { flex: 1; color: var(--text-muted); }
.stage-bar-meta { color: var(--text); font-weight: 600; font-size: 11.5px; }
.stage-bar-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.stage-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease;
  min-width: 2px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 12px;
}
.kpi {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-decoration: none;
  color: var(--text);
  text-align: center;
  transition: border-color .12s;
}
.kpi:hover { border-color: var(--accent); }
.kpi-num {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.kpi-num.accent { color: var(--accent); }
.kpi-num.danger { color: var(--danger); }
.kpi-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

.mini-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mini-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-size: 12.5px;
  transition: background .12s;
}
.mini-item:hover { background: var(--surface-2); }
.mini-item svg { width: 14px; height: 14px; stroke-width: 1.75; color: var(--text-muted); flex-shrink: 0; }
.mini-sub { color: var(--text-muted); font-size: 11.5px; margin-left: auto; }

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
  transition: background .12s;
}
.activity-item:hover { background: var(--surface-2); }
.activity-body { flex: 1; min-width: 0; }
.activity-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.activity-author { font-weight: 600; font-size: 12.5px; }
.activity-time { font-size: 10.5px; color: var(--text-dim); }
.activity-text {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* ----- График дашборда ----- */
.chart-widget { }
.chart-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}
.chart-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.chart-controls select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}
.chart-controls select:focus { outline: none; border-color: var(--accent); }
.chart-area {
  height: 220px;
  display: flex;
  align-items: flex-end;
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 100%;
  height: 100%;
}
.bar-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  height: 100%;
}
.bar-track {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--surface-2);
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}
.bar-fill {
  background: var(--bar-color, var(--accent));
  border-radius: 4px 4px 0 0;
  transition: height .25s ease;
  min-height: 2px;
}
.bar-val {
  position: absolute;
  top: 4px;
  left: 0; right: 0;
  text-align: center;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 1px 2px rgba(0,0,0,.3);
  pointer-events: none;
}
.bar-label {
  font-size: 10px;
  text-align: center;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Настройки ---------- */
.settings-view {
  max-width: 840px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.settings-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.settings-head { margin-bottom: 16px; }
.settings-head h3 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.settings-head p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
}
.settings-body { display: flex; flex-direction: column; gap: 14px; }
.settings-hint {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--surface-2);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}
.settings-saved {
  font-size: 12.5px;
  color: var(--success);
  margin-left: 12px;
  align-self: center;
}

.theme-options {
  display: flex;
  gap: 12px;
}
.theme-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.theme-option:hover { border-color: var(--accent); }
.theme-option.active { border-color: var(--accent); background: var(--accent-tint); }
.theme-preview {
  width: 56px;
  height: 36px;
  border-radius: 6px;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.theme-preview.dark { background: #0F1419; }
.theme-preview.dark::after { content: ""; position: absolute; bottom: 4px; left: 4px; right: 4px; height: 8px; background: #1F9C4D; border-radius: 2px; }
.theme-preview.light { background: #F7F9F7; border-color: #D4E0D7; }
.theme-preview.light::after { content: ""; position: absolute; bottom: 4px; left: 4px; right: 4px; height: 8px; background: #157A3B; border-radius: 2px; }

.integrations-grid {
  display: grid;
  gap: 8px;
}
.integration-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color .12s;
}
.integration-card.open { border-color: var(--accent); }
.integration-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
}
.integration-title { font-weight: 600; font-size: 13.5px; }
.integration-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.integration-status {
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface);
  color: var(--text-dim);
}
.integration-status.on { background: rgba(34, 197, 94, .15); color: var(--success); }
.integration-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  margin-top: 0;
}
.integration-form .field { margin: 0; }
.integration-form input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.integration-form input:focus { outline: none; border-color: var(--accent); }
.integration-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.integration-actions .btn { width: auto; padding: 8px 18px; }

/* Typeahead (combobox с поиском) */
.typeahead {
  position: relative;
  width: 100%;
}
.typeahead-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  text-align: left;
}
.typeahead.open .typeahead-trigger { border-color: var(--accent); }
.typeahead-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typeahead-placeholder { color: var(--text-dim); }
.typeahead-sub { color: var(--text-muted); font-weight: 400; font-size: 12.5px; }
.typeahead-caret { color: var(--text-dim); font-size: 11px; margin-left: 8px; }
.typeahead-dropdown[hidden] { display: none !important; }
.typeahead-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  max-height: 280px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.typeahead-search {
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.typeahead-search:focus { outline: none; }
.typeahead-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.typeahead-item {
  width: 100%;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.typeahead-item:hover { background: var(--surface-hover); }
.typeahead-item.selected { background: var(--accent-tint); color: var(--accent-hover); }
.ta-item-name { font-weight: 500; }
.ta-item-sub { font-size: 11.5px; color: var(--text-muted); }
.typeahead-empty {
  padding: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
}
.typeahead-create-btn {
  margin-top: 4px;
  padding: 8px 10px;
  border: 0;
  border-top: 1px solid var(--border-soft);
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.typeahead-create-btn:hover { background: var(--accent-tint); }

/* Custom fields settings */
.fields-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.custom-field-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.4fr auto;
  gap: 8px;
  align-items: center;
}
.custom-field-row input, .custom-field-row select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.custom-field-row input:focus, .custom-field-row select:focus { outline: none; border-color: var(--accent); }
@media (max-width: 720px) {
  .custom-field-row { grid-template-columns: 1fr; }
}

/* Employee & role rows */
.employees-list, .roles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.employee-row, .role-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.employee-body, .role-body { flex: 1; min-width: 0; }
.employee-name, .role-name { font-weight: 600; font-size: 13.5px; }
.employee-name .badge, .role-name .badge { margin-left: 6px; font-size: 9.5px; }
.employee-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.role-perms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.employee-actions, .role-actions { display: flex; gap: 6px; }

.employee-form, .role-form {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-top: 8px;
}
.role-perm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

/* ---------- Документы ---------- */
.docs-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.doc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.doc-head h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.doc-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
}
.doc-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
}
.doc-empty h4 {
  margin: 0 0 6px;
  font-size: 16px;
}
.doc-empty p {
  margin: 0;
  color: var(--text-muted);
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.doc-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .12s, transform .08s;
}
.doc-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.doc-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.doc-card-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--accent-tint);
  color: var(--accent);
}
.doc-card-icon svg { width: 16px; height: 16px; stroke-width: 1.75; }
.doc-card-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.doc-card h4 {
  margin: 0;
  font-size: 14px;
  line-height: 1.35;
}
.doc-card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 38px;
}
.doc-card-foot {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  color: var(--text-dim);
}

.doc-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.doc-page-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.doc-page-title h3 {
  margin: 0;
  font-size: 20px;
  line-height: 1.3;
}
.doc-page-title p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}
.doc-page-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 14px;
  align-items: start;
}
.doc-article {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.doc-side {
  position: sticky;
  top: 14px;
}
.doc-mobile-access { display: none; }

.doc-page-content {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.doc-toc {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.doc-toc a {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  background: var(--accent-tint);
  padding: 5px 9px;
  border-radius: 999px;
}
.doc-toc a:hover { background: var(--accent-tint-strong); }
.doc-section h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.doc-section p {
  margin: 0 0 8px;
  line-height: 1.55;
}
.doc-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}
.doc-list.ordered { padding-left: 20px; }
.doc-formula {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.6;
}
.doc-note {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.doc-access-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.doc-access-panel h4 {
  margin: 0;
  font-size: 14px;
}
.doc-access-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.doc-access-mode button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}
.doc-access-mode button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-tint);
}
.doc-access-selected.is-hidden { display: none; }
.doc-access-list {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.doc-access-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.doc-access-item:last-child { border-bottom: 0; }
.doc-access-item.is-hidden { display: none; }
.doc-access-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.doc-access-item-body b {
  font-size: 12.5px;
  line-height: 1.3;
}
.doc-access-item-body small {
  font-size: 11.5px;
  color: var(--text-muted);
}
.doc-access-item input[type="checkbox"] { width: 16px; height: 16px; }
.doc-access-save { width: 100%; justify-content: center; }
.doc-access-save:disabled { opacity: .55; cursor: not-allowed; }
.doc-access-hint {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.45;
}
.doc-access-modal .modal-header { padding-bottom: 14px; }
.doc-access-modal-body { padding: 0 18px 18px; overflow: auto; }

/* ---------- Калькулятор мотивации ---------- */
.calc-wrap {
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.calc-params summary {
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.calc-grid-main { margin-top: 6px; }
.calc-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.calc-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}
.calc-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.calc-output {
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.calc-output-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.calc-output-grid div {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 9px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.calc-output-grid span {
  color: var(--text-muted);
  font-size: 12px;
}
.calc-output-grid strong {
  color: var(--text);
  font-size: 12.5px;
}
.calc-kpi-bar {
  height: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.calc-kpi-bar span {
  display: block;
  height: 100%;
  background: var(--success);
  transition: width .12s linear;
}
.calc-kpi-bar.is-below-threshold span { background: var(--danger); }
.calc-kpi-label {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
}
.calc-kpi-label.is-danger { color: var(--danger); }
.calc-note {
  font-size: 12px;
  color: var(--text-muted);
}
.calc-total {
  background: var(--accent-tint);
  border: 1px solid var(--accent-tint-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.calc-total b {
  color: var(--accent);
  font-size: 16px;
}
.calc-scenarios-wrap { overflow-x: auto; }
.calc-scenarios {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
.calc-scenarios th,
.calc-scenarios td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
  text-align: left;
}
.calc-scenarios th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.calc-scenarios td.is-total {
  color: var(--success);
  font-weight: 700;
}

/* ---------- Настройки: модалка документов сотрудника ---------- */
.doc-emp-modal-body {
  padding: 0 18px 18px;
  overflow: auto;
}
.doc-emp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.doc-emp-item {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.doc-emp-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.doc-emp-title {
  font-size: 13px;
  font-weight: 600;
}
.doc-emp-meta {
  color: var(--text-muted);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.doc-emp-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.doc-emp-toggle input {
  width: 16px;
  height: 16px;
}

/* About block */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.about-grid > div {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.about-label {
  display: block;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.about-grid strong {
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
}
.changelog {
  margin-bottom: 12px;
}
.settings-section-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.changelog-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-soft);
}
.changelog-item:last-child { border-bottom: 0; }
.changelog-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-tint);
  padding: 4px 10px;
  border-radius: 999px;
  align-self: flex-start;
  white-space: nowrap;
}
.changelog-body { flex: 1; min-width: 0; }
.changelog-title { font-size: 13.5px; font-weight: 500; line-height: 1.4; }
.changelog-date { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.brand { cursor: pointer; transition: opacity .12s; }
.brand:hover { opacity: 0.8; }

.danger-zone { border-color: rgba(239, 68, 68, .25); }
.danger-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.danger-row > div:first-child { flex: 1; min-width: 220px; }
.danger-title { font-weight: 600; font-size: 13.5px; }
.danger-sub { color: var(--text-muted); font-size: 12px; margin-top: 3px; }

@media (max-width: 1080px) {
  .doc-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-page-layout { grid-template-columns: 1fr; }
  .doc-side { display: none; }
  .doc-mobile-access { display: block; }
  .calc-grid,
  .calc-output-grid { grid-template-columns: 1fr; }
}

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 56px auto 1fr;
    grid-template-areas:
      "topbar"
      "side"
      "main";
  }
  .sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
    gap: 4px;
  }
  .brand, .nav-section, .nav-spacer { display: none; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .nav-item.active::before { display: none; }

  .contacts-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(180px, 34vh) auto minmax(240px, 1fr);
    height: auto;
  }
  .docs-view { gap: 10px; }
  .doc-grid { grid-template-columns: 1fr; }
  .doc-page-title h3 { font-size: 18px; }
  .doc-page-head { align-items: flex-start; }
  .doc-article { padding: 12px; }
  .doc-emp-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .doc-emp-toggle { align-self: stretch; justify-content: flex-end; }
  .doc-access-modal {
    max-width: 100%;
    max-height: calc(100vh - 28px);
  }
  .calc-scenarios { min-width: 620px; }
  .contacts-list-pane { max-height: 34vh; }
  .contacts-chat-pane { min-height: 260px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ===========================================================================
   Карточка сделки v2: блок контакта, нижняя панель действий, плавающее WA-окно
   ─ добавлено в рамках редизайна модалки (см. app/views/deals.js).
   =========================================================================== */

/* --- Блок контакта в карточке сделки --- */
.deal-contact-block { margin-bottom: 14px; }
.deal-contact-block .dcc-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Карточка контакта (режим view) */
.deal-contact-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.dcc-info { flex: 1; min-width: 0; }
.dcc-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dcc-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.dcc-line svg { width: 12px; height: 12px; stroke-width: 1.75; flex-shrink: 0; }
.dcc-line span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dcc-line.dcc-meta { color: var(--text-dim); font-size: 12px; }
.dcc-actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Picker-режим (typeahead inline) */
.deal-contact-pick .dcc-cancel { margin-top: 6px; font-size: 12px; }
.dcc-pick-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.deal-contact-creating {
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
}
.dcc-type-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.dcc-type-btn {
  border: none;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.dcc-type-btn.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.dcc-create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dcc-create-grid .field { margin-bottom: 0; }
.dcc-create-grid input,
.dcc-create-grid select,
.dcc-create-grid textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.dcc-create-grid input:focus,
.dcc-create-grid select:focus,
.dcc-create-grid textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.dcc-create-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Edit-режим — inline-форма правки полей контакта */
.deal-contact-editing {
  padding: 12px 14px;
  background: var(--accent-tint);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
}
.dce-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.dce-grid input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.dce-grid input:focus { outline: none; border-color: var(--accent); }
.dce-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Маленькая модификация кнопок */
.btn-sm { font-size: 12px; padding: 6px 12px; }
.btn-ghost.btn-sm { padding: 6px 10px; }
.btn-primary.btn-sm { padding: 6px 12px; }

/* --- Нижняя панель действий карточки сделки --- */
.deal-action-bar {
  display: flex;
  gap: 8px;
  padding: 12px 22px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
  flex-shrink: 0;
}
.deal-action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
}
.deal-action-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--accent);
  color: var(--accent-hover);
}
.deal-action-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.deal-action-btn svg { width: 14px; height: 14px; stroke-width: 1.75; }
.deal-action-btn .dab-emoji { font-size: 14px; line-height: 1; }
/* WhatsApp как главное действие — фирменный зелёный */
.deal-action-btn-primary {
  background: #25d366;
  border-color: #1fb95a;
  color: white;
  flex: 1.4;
}
.deal-action-btn-primary:hover:not(:disabled) {
  background: #1fb95a;
  border-color: #1fb95a;
  color: white;
}

/* --- Плавающее WhatsApp-окно (поверх карточки сделки) --- */
.wa-float {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .15);
  display: flex;
  flex-direction: column;
  z-index: 200; /* выше modal-backdrop (100) */
  overflow: hidden;
  animation: slideUp .2s ease-out;
}
.wa-float-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
  flex-shrink: 0;
}
.wa-float-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.wa-float-meta { flex: 1; min-width: 0; }
.wa-float-head-actions { display: inline-flex; gap: 2px; align-items: center; }
.wa-float-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wa-float-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}
.wa-float-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
}
.wa-float-search input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  padding: 7px 9px;
}
.wa-float-empty {
  padding: 28px 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}
.wa-float-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 240px;
  max-height: 380px;
  padding: 12px 14px;
  background: var(--surface);
}
.wa-float .chat-compose {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
}
.wa-float .chat-compose-media {
  padding: 0 12px 10px;
  border-top: 0;
}
.wa-day-divider {
  display: flex;
  justify-content: center;
  margin: 6px 0 2px;
}
.wa-day-divider span {
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  font-size: 10.5px;
  padding: 2px 8px;
  text-transform: lowercase;
}
.msg-status {
  color: var(--wa-muted);
  font-size: 10px;
  margin-left: 2px;
}
.msg-status.delivered { color: #22c55e; }

.wa-float-compose {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}
.wa-compose-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border-soft);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.wa-compose-icon-btn svg {
  width: 14px;
  height: 14px;
}
.wa-compose-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.wa-float-compose input[name="text"] {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
}
.wa-float-compose input[name="text"]:focus {
  outline: none;
  border-color: var(--accent);
}
.wa-compose-send-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.wa-compose-send-btn svg {
  width: 14px;
  height: 14px;
}
.wa-float .chat-compose-media.is-hidden {
  display: none;
}

/* --- Редактируемые поля сделки (iter 3) --- */
.deal-fields-editor {
  margin-top: 4px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.deal-fields-editor-head {
  padding: 8px 12px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
}
.field-row {
  position: relative;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.field-row:last-child { border-bottom: none; }
.field-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}
.field-label-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.field-label-ico svg {
  width: 12px;
  height: 12px;
  stroke-width: 2;
}
.field-action {
  margin-left: 0;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 20px;
  height: 20px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  cursor: pointer;
  transition: opacity .12s ease, background .12s ease;
}
.field-label .field-action:first-of-type { margin-left: auto; }
.field-row:hover .field-action { opacity: .6; }
.field-action:hover {
  opacity: 1 !important;
  background: var(--surface-hover);
}
.field-action svg {
  width: 12px;
  height: 12px;
}
.field-value {
  min-height: 32px;
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.field-value:hover {
  border-color: var(--accent);
}
.field-value a { color: var(--accent-hover); text-decoration: none; }
.field-value a:hover { text-decoration: underline; }

.field-value-comm {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.field-value-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.comm-ico {
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  color: var(--text-muted);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.comm-ico:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}
.comm-ico svg {
  width: 12px;
  height: 12px;
}

.cf-pill-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.cf-pill {
  background: var(--accent-tint);
  color: var(--accent-hover);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  line-height: 1.3;
  white-space: nowrap;
}
.cf-boolean.yes { color: #14804a; font-weight: 600; }
.cf-boolean.no { color: var(--text-dim); }
.cf-inline-sub {
  color: var(--text-muted);
  font-size: 12px;
  margin-left: 6px;
}
.cf-employee {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.cf-textarea {
  white-space: pre-wrap;
  line-height: 1.45;
}

.field-popover {
  position: absolute;
  top: calc(100% - 2px);
  left: 12px;
  right: 12px;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, .24);
  padding: 10px 12px;
}
.field-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.field-popover-head-main {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.field-popover-ico {
  width: 12px;
  height: 12px;
  display: inline-flex;
}
.field-popover-ico svg {
  width: 12px;
  height: 12px;
}
.field-popover-gear {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.field-popover-gear:hover {
  background: var(--surface-hover);
  color: var(--accent-hover);
}
.field-popover-gear svg {
  width: 12px;
  height: 12px;
}
.field-popover-input,
.field-popover select,
.field-popover textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.field-popover-input:focus,
.field-popover select:focus,
.field-popover textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field-popover-multi {
  display: grid;
  gap: 6px;
}
.field-popover-multi-opt {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.field-bool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.field-row-add {
  background: var(--surface);
  padding: 10px 12px;
}
.add-field-btn {
  width: 100%;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-dim);
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.add-field-btn:hover {
  color: var(--accent-hover);
  border-color: var(--accent);
}

.add-field-popover {
  left: 0;
  right: 0;
  top: calc(100% + 8px);
}
.field-type-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 10px;
}
.field-type-opt {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px;
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.field-type-opt.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.field-type-opt-ico svg {
  width: 12px;
  height: 12px;
}
.new-field-options {
  display: grid;
  gap: 6px;
}
.new-field-option-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px auto;
  gap: 6px;
  align-items: center;
}
.new-field-option-row input,
.new-field-option-row select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.new-field-option-row button { width: 28px; height: 28px; }
.field-popover-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 8px;
}

.deal-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.deal-micro-pill,
.deal-micro-text {
  font-size: 11px;
}
.deal-micro-text {
  color: var(--text-dim);
}

.deal-action-btn-single {
  flex: 1 !important;
}

/* --- Плавающие comm-окна --- */
.comm-dialogs-layer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 230;
  pointer-events: none;
}
.comm-dialog {
  position: fixed;
  bottom: 16px;
  width: 380px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  overflow: hidden;
  pointer-events: auto;
}
.comm-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.comm-dialog-title-wrap {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.comm-dialog-ico {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.comm-dialog-ico svg {
  width: 13px;
  height: 13px;
}
.comm-dialog-title-main {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.comm-dialog-title-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.comm-dialog-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.comm-dialog-body {
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.comm-dialog-body input,
.comm-dialog-body select,
.comm-dialog-body textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
.comm-dialog-body input:focus,
.comm-dialog-body select:focus,
.comm-dialog-body textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.comm-dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.comm-call-status {
  font-size: 12px;
  color: var(--text-muted);
}
.comm-call-timer {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.comm-tray {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}
.comm-tray-item {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, .25);
}
.comm-tray-item:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}
.comm-tray-item svg {
  width: 15px;
  height: 15px;
}

/* Мобильная адаптация — окно во всю ширину */
@media (max-width: 640px) {
  .wa-float {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
  }
  .field-popover {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    margin: 0;
    border-radius: 12px 12px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    z-index: 260;
    max-height: 70vh;
    overflow: auto;
  }
  .dcc-create-grid {
    grid-template-columns: 1fr;
  }
  .field-type-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .new-field-option-row {
    grid-template-columns: 1fr;
  }
  .comm-dialog {
    left: 8px;
    right: 8px !important;
    width: auto;
  }
  .comm-tray {
    right: 8px;
    bottom: 8px;
  }
}

/* =====================================================================
   Redesign v3: Contacts / Dashboard / Feed / Tasks
   ===================================================================== */

.seg {
  display: flex;
  gap: 0;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.seg button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.seg button.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 0 0 .5px var(--border);
}

/* --- Contacts v3 --- */
.contacts-layout-v3 {
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
}
.contacts-layout-v3 .contacts-list-pane {
  min-height: 0;
}
.contacts-list-foot {
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}
.contacts-list-foot .btn-ghost {
  width: 100%;
  justify-content: center;
}
.contact-detail-card {
  min-height: calc(100vh - 56px - 48px - 48px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.contact-detail-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.contact-head-text {
  flex: 1;
  min-width: 0;
}
.contact-meta-line {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 2px;
}
.contact-detail-head h2 {
  margin: 0;
  font-size: 29px;
  line-height: 1.12;
}
.contact-head-actions {
  display: inline-flex;
  gap: 6px;
}
.contact-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px;
}
.contact-info-cell {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
}
.contact-info-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-dim);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}
.contact-info-label svg {
  width: 12px;
  height: 12px;
  stroke-width: 1.9;
}
.contact-info-value {
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  min-height: 18px;
}
.contact-info-value a {
  color: var(--accent);
  text-decoration: none;
}
.contact-info-value a:hover {
  text-decoration: underline;
}
.contact-tags-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.contact-related-deals {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}
.contact-related-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}
.contact-deals-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.contact-deal-pill {
  min-width: 220px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  text-decoration: none;
  color: var(--text);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 7px;
  align-items: center;
  background: var(--surface-2);
}
.contact-deal-pill:hover {
  border-color: var(--accent);
}
.contact-deal-pill .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.contact-deal-pill .title {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.contact-deal-pill .sum {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
}
.contact-deals-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 8px 4px;
}
.contact-activity {
  min-height: 250px;
  display: flex;
  flex-direction: column;
}
.contact-note-compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.contact-note-compose textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  resize: vertical;
}
.contact-note-compose textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.contact-note-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.contact-action-bar {
  margin-top: auto;
}
.contact-global-empty {
  min-height: calc(100vh - 190px);
  display: grid;
  place-content: center;
}
.contact-empty-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.contact-form-hint {
  padding: 10px 22px 0;
  color: var(--text-dim);
  font-size: 12px;
}
.contact-form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.contact-form-grid .field-wide {
  grid-column: 1 / -1;
}
.flbl {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 10.5px;
  color: var(--text-dim);
}
.contact-type-seg {
  max-width: 280px;
}

/* --- Dashboard v3 --- */
.dash-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.kpi-card .label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.kpi-card .value {
  font-size: 18px;
  font-weight: 600;
  margin-top: 6px;
}
.kpi-card .hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}
.kpi-card.is-success .value {
  color: var(--success);
}
.dash-stage-block {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.dash-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.dash-stage-head h3 {
  margin: 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.dash-period-switch {
  display: inline-flex;
  gap: 4px;
}
.dash-period-btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}
.dash-period-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}
.dash-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}
.stage-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stage-card.is-muted {
  opacity: .5;
}
.stage-card-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 9px;
}
.stage-card-head .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--stage-color);
}
.stage-card-title {
  font-size: 12px;
  font-weight: 600;
  flex: 1;
}
.stage-card-delta {
  font-size: 11px;
  font-weight: 600;
}
.stage-card-delta.up { color: var(--success); }
.stage-card-delta.dn { color: var(--danger); }
.stage-card-delta.flat { color: var(--text-dim); }
.stage-card-numbers {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 8px;
}
.stage-card-numbers .count {
  color: var(--stage-color);
  font-size: 22px;
  font-weight: 700;
}
.stage-card-numbers .count-label {
  font-size: 11px;
  color: var(--text-dim);
}
.stage-card-numbers .sum {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}
.stage-card-spark {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 36px;
}
.stage-card-spark span {
  flex: 1;
  background: var(--stage-color);
  border-radius: 2px 2px 0 0;
}
.dash-bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.dash-bottom-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 12px;
}
.dash-bottom-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.dash-bottom-head h4 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.dash-bottom-head a {
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
}
.dash-task-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}
.tkpi {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--surface-2);
  padding: 8px;
  text-align: center;
}
.tkpi span {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.tkpi small {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}
.tkpi.danger span,
.tkpi.danger small { color: var(--danger); }
.tkpi.warn span,
.tkpi.warn small { color: var(--warning); }
.dash-mini-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-mini-item,
.dash-activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text);
}
.dash-mini-item:hover,
.dash-activity-item:hover {
  background: var(--surface-2);
}
.dash-mini-item svg {
  width: 14px;
  height: 14px;
  color: var(--text-dim);
}
.dash-activity-body {
  min-width: 0;
  flex: 1;
}
.dash-activity-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
}
.dash-activity-head strong {
  font-weight: 600;
}
.dash-activity-head span {
  color: var(--text-dim);
}
.dash-activity-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-empty {
  font-size: 12px;
  color: var(--text-dim);
  padding: 6px 2px;
}

/* --- Feed v3 --- */
.feed-view {
  max-width: 760px;
  margin: 0 auto;
  gap: 10px;
}
.feed-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.feed-head h3 {
  margin: 0;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.feed-head-tabs {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.feed-head-tab {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  font-size: 12px;
  padding: 6px 11px;
  cursor: pointer;
}
.feed-head-tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
}
.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.feed-composer-wrap {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
}
.feed-card .composer {
  border: 0;
  background: transparent;
  padding: 0;
}
.feed-card .composer textarea {
  min-height: 38px;
  resize: none;
}
.feed-card .composer-actions {
  justify-content: flex-start;
  padding-top: 2px;
}
.feed-posts {
  display: flex;
  flex-direction: column;
}
.feed-post {
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
}
.feed-post:first-child {
  border-top: 0;
}
.feed-post .post-head {
  margin: 0;
  align-items: flex-start;
}
.post-body-wrap {
  flex: 1;
  min-width: 0;
}
.post-head-line {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}
.post-author {
  font-weight: 600;
  font-size: 13px;
}
.post-time {
  font-size: 11px;
  color: var(--text-dim);
}
.post-vis {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 8px;
}
.post-text {
  font-size: 13.5px;
  line-height: 1.52;
  margin-bottom: 8px;
}
.post-actions {
  display: flex;
  gap: 4px;
  margin-left: -8px;
}
.post-action {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.post-action svg {
  width: 14px;
  height: 14px;
}
.post-action:hover {
  background: var(--surface-2);
  color: var(--text);
}
.post-action.active {
  color: var(--danger);
}
.comments-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feed-more-comments {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  padding: 0;
  text-align: left;
  cursor: pointer;
}
.comment-time {
  margin-left: 4px;
  font-size: 11px;
  color: var(--text-dim);
}
.comment-form {
  display: flex;
  align-items: center;
  gap: 8px;
}
.comment-form input {
  flex: 1;
  border-radius: 999px;
}

/* --- Tasks v3 --- */
.tasks-view {
  max-width: 920px;
  margin: 0 auto;
}
.tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.tasks-filter {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tasks-filter-tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 12px;
  cursor: pointer;
}
.tasks-filter-tab.on {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
  font-weight: 600;
}
.tasks-filter-tab .filter-count {
  margin-left: 4px;
  opacity: .75;
}
.tasks-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.task-group {
  padding: 6px 0;
}
.task-group + .task-group {
  border-top: 1px solid var(--border-soft);
}
.task-group-head {
  padding: 10px 16px 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.task-group-head .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.task-group-head .group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}
.task-group-head .group-count {
  background: var(--surface-2);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
}
.task-group-head.overdue .group-title,
.task-group-head.overdue .group-count {
  color: var(--danger);
  background: rgba(239, 68, 68, .1);
}
.task-group-head.today .group-title,
.task-group-head.today .group-count {
  color: var(--warning);
  background: rgba(245, 158, 11, .14);
}
.task-list {
  display: flex;
  flex-direction: column;
}
.task-row {
  padding: 10px 16px;
  border-top: 1px solid var(--border-soft);
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  border-bottom: 0;
  align-items: center;
  gap: 10px;
}
.task-row:hover {
  background: var(--surface-2);
}
.task-body {
  flex: 1;
  min-width: 0;
}
.task-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 3px;
}
.task-desc {
  font-size: 11.5px;
}
.prio-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.prio-dot.prio-high { background: var(--danger); }
.prio-dot.prio-med { background: var(--warning); }
.prio-dot.prio-low { background: var(--text-dim); }
.task-meta {
  display: flex;
  gap: 11px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-dim);
}
.task-meta .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.task-meta .meta-item svg {
  width: 11px;
  height: 11px;
  stroke-width: 1.8;
}
.task-meta .meta-item.overdue {
  color: var(--danger);
}
.task-assignee {
  flex-shrink: 0;
}
.task-row.done .task-title {
  text-decoration: line-through;
  color: var(--text-dim);
}
.task-check.checked {
  background: var(--success);
}

@media (max-width: 980px) {
  .dash-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .dash-bottom-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .contacts-layout-v3 {
    grid-template-columns: 1fr;
    height: auto;
  }
  .contacts-layout-v3 .contacts-list-pane {
    max-height: 48vh;
  }
  .contact-info-grid {
    grid-template-columns: 1fr;
  }
  .contact-form-grid {
    grid-template-columns: 1fr;
  }
  .contact-empty-actions {
    flex-direction: column;
  }
  .tasks-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .tasks-filter {
    width: 100%;
  }
  .tasks-filter-tab {
    flex: 1;
  }
  .feed-head {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ----- Склад ----- */
.wh-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wh-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}
.wh-title-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}
.wh-title-wrap h3 {
  margin: 0;
  font-size: 20px;
}
.wh-title-wrap p {
  margin: 2px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}
.wh-title-ico {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--accent);
}
.wh-title-ico svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}
.wh-top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.wh-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.wh-tab {
  text-decoration: none;
  color: var(--text-muted);
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 5px;
}
.wh-tab.active {
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.wh-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.wh-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.wh-toolbar select,
.wh-toolbar label select {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}
.wh-toolbar-stock {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  align-items: center;
}
.wh-toolbar-stock label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.wh-table-wrap {
  overflow: auto;
}
.wh-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}
.wh-table th,
.wh-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 13px;
  text-align: left;
  vertical-align: middle;
}
.wh-table th {
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.wh-row {
  cursor: pointer;
}
.wh-row:hover td {
  background: var(--surface-hover);
}
.wh-product-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.wh-photo-ph {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  display: grid;
  place-items: center;
  color: var(--text-dim);
}
.wh-photo-ph svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.8;
}
.wh-product-name {
  font-weight: 600;
}
.wh-product-sub {
  color: var(--text-dim);
  font-size: 11.5px;
  margin-top: 1px;
}
.wh-stock.is-ok { color: var(--success); font-weight: 700; }
.wh-stock.is-low { color: var(--warning); font-weight: 700; }
.wh-stock.is-out { color: var(--danger); font-weight: 700; }
.wh-exp {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid transparent;
}
.wh-exp-muted {
  color: var(--text-dim);
  border-color: var(--border-soft);
}
.wh-exp-ok {
  color: var(--success);
  border-color: rgba(34, 197, 94, .35);
}
.wh-exp-caution {
  color: var(--warning);
  border-color: rgba(245, 158, 11, .35);
}
.wh-exp-warn {
  color: var(--warning);
  border-color: rgba(245, 158, 11, .55);
  background: rgba(245, 158, 11, .12);
}
.wh-exp-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, .55);
  background: rgba(239, 68, 68, .12);
}
.dupes-badge.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-hover);
}
.wh-list-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 12px;
}
.wh-page {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.wh-empty-row {
  padding: 18px 8px;
  text-align: center;
  color: var(--text-muted);
}
.wh-stock-group-row td {
  background: var(--surface-2);
  border-bottom-color: var(--border);
}
.wh-stock-group-head {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
}
.wh-link-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.wh-link-btn:hover {
  color: var(--accent-hover);
}
.wh-stock-row.is-expired td {
  background: rgba(239, 68, 68, .14);
}
.wh-stock-row.is-30 td {
  background: rgba(245, 158, 11, .12);
}
.wh-stock-row.is-90 td {
  background: rgba(245, 158, 11, .06);
}
.wh-row-actions {
  display: inline-flex;
  gap: 6px;
}
.wh-row-actions .btn-ghost {
  white-space: nowrap;
}
.wh-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 12px;
}
.wh-checkbox input[type="checkbox"] {
  accent-color: var(--accent);
}
.wh-checkbox-block {
  min-height: 38px;
  margin: 2px 0;
}
.wh-product-modal-body {
  grid-template-columns: 1.1fr .9fr;
}
.wh-form-col .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.wh-form-col .field-wide {
  grid-column: 1 / -1;
}
.wh-form-buttons {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.wh-side-col {
  background: var(--surface-2);
}
.wh-side-tabs {
  background: var(--surface-2);
}
.wh-side-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}
.wh-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  gap: 8px;
}
.wh-side-table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  background: var(--surface);
}
.wh-side-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}
.wh-side-table th,
.wh-side-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12px;
  text-align: left;
}
.wh-side-table th {
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10.5px;
}
.wh-side-table tr.is-expired td {
  background: rgba(239, 68, 68, .14);
}
.wh-side-table tr.is-30 td {
  background: rgba(245, 158, 11, .12);
}
.wh-side-table tr.is-90 td {
  background: rgba(245, 158, 11, .06);
}
.wh-side-empty {
  padding: 24px 10px;
  text-align: center;
  color: var(--text-muted);
}
.wh-inline-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 10px;
}
.wh-inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.wh-inline-grid .field {
  margin: 0;
}
.wh-inline-grid .field-wide {
  grid-column: 1 / -1;
}
.wh-inline-grid input {
  padding: 8px 10px;
}
.wh-inline-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.wh-modal-foot-note {
  color: var(--text-muted);
  font-size: 12px;
}
.wh-td-sub {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 11px;
}

@media (max-width: 920px) {
  .wh-top-actions {
    width: 100%;
  }
  .wh-top-actions .btn-primary {
    margin-left: auto;
  }
  .wh-toolbar {
    align-items: stretch;
  }
  .wh-toolbar select {
    flex: 1;
    min-width: 180px;
  }
  .wh-list-foot {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 760px) {
  .wh-product-modal-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .wh-form-col {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
    max-height: 46vh;
  }
  .wh-inline-grid {
    grid-template-columns: 1fr;
  }
}

/* Contacts: filters + bulk + list view */
.contacts-view-switch {
  display: inline-flex;
  gap: 6px;
}

.contacts-view-switch .btn-ghost.active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--text);
}

.contacts-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(191, 136, 74, 0.18);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.contacts-listv {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.contacts-listv-toolbar {
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.contacts-listv-head {
  margin-right: auto;
  font-weight: 700;
}

.contacts-listv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.contacts-listv-search {
  min-width: 300px;
}

.contacts-filter-row {
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.contacts-filter-chip {
  position: relative;
}

.contacts-filter-chip > summary {
  list-style: none;
  cursor: pointer;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface-2);
  color: var(--text);
}

.contacts-filter-chip[open] > summary {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.contacts-filter-chip > summary::-webkit-details-marker {
  display: none;
}

.contacts-filter-menu {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  max-height: 320px;
  overflow: auto;
  z-index: 20;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contacts-filter-menu label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.contacts-date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.contacts-date-range input {
  min-width: 0;
}

.contacts-filter-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 10px 6px;
}

.contacts-filter-reset {
  margin-left: auto;
}

.contacts-bulk-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-tint);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.contacts-bulk-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.contacts-bulk-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.contacts-bulk-menu-wrap {
  position: relative;
}

.contacts-bulk-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 25;
  min-width: 220px;
  max-width: 280px;
  padding: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contacts-table-wrap {
  overflow: auto;
}

.contacts-table,
.contacts-trash-table {
  width: 100%;
  border-collapse: collapse;
}

.contacts-table th,
.contacts-table td,
.contacts-trash-table th,
.contacts-trash-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

.contacts-table tbody tr:hover {
  background: var(--surface-hover);
}

.contacts-table tbody tr.is-selected {
  background: var(--accent-tint);
}

.contacts-sort-btn {
  appearance: none;
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.contacts-cell-main {
  font-weight: 600;
}

.contacts-cell-sub {
  color: var(--text-dim);
  font-size: 12px;
}

.contacts-source-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(191, 136, 74, 0.16);
  color: var(--accent);
}

.contacts-listv-foot {
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 13px;
}

.contacts-trash-note {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
  background: rgba(191, 136, 74, 0.08);
}

.contacts-trash-wrap {
  max-height: 65vh;
  overflow: auto;
}

.contacts-trash-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-link {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* Contacts: imports history */
.imports-history-note {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-muted);
  background: rgba(191, 136, 74, 0.08);
}

.imports-history-list {
  padding: 14px 16px;
  max-height: 62vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-batch-card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.import-batch-card.is-latest {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(191, 136, 74, 0.18) inset;
}

.import-batch-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
}

.import-batch-meta {
  margin-top: 4px;
  color: var(--text-muted);
}

.import-batch-stats {
  margin-top: 6px;
  color: var(--text-dim);
}

.import-batch-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.imports-history-foot {
  padding: 0 16px 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.deal-contact-trash-note {
  border: 1px solid var(--warning);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  background: var(--accent-tint);
  color: var(--warning);
  font-weight: 600;
}

@media (max-width: 900px) {
  .contacts-listv-search {
    min-width: 220px;
    flex: 1;
  }
  .contacts-bulk-bar {
    position: static;
  }
  .import-batch-card {
    grid-template-columns: 1fr;
  }
  .import-batch-actions {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Warehouse */
.whm-view {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.whm-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.whm-section .alert-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
}

.whm-section .alert-bar.danger {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.35);
}

.whm-alert-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--warning);
  flex: 0 0 auto;
}

.whm-section .alert-bar.danger .whm-alert-ico {
  color: var(--danger);
}

.whm-alert-ico svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}

.whm-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.whm-toolbar select,
.whm-toolbar .search-input,
.whm-toolbar .search-input input {
  min-height: 38px;
}

.whm-search {
  min-width: 260px;
  max-width: 420px;
  flex: 1;
}

.whm-card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.whm-pad {
  padding: 14px 16px;
}

.whm-table {
  width: 100%;
  border-collapse: collapse;
}

.whm-table th,
.whm-table td {
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

.whm-table th {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.whm-table tbody tr:hover td {
  background: var(--surface-hover);
}

.whm-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.whm-empty {
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
}

.whm-product-name {
  font-weight: 600;
}

.whm-product-sub {
  color: var(--text-dim);
  font-size: 12px;
}

.whm-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
}

.whm-badge.is-danger {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.12);
}

.whm-badge.is-warning {
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.1);
}

.whm-badge.is-ok {
  color: var(--success);
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.1);
}

.whm-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.whm-kpi-grid {
  margin-bottom: 0;
}

.whm-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.whm-mini-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.whm-mini-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.whm-mini-list a {
  color: var(--text);
  text-decoration: none;
}

.whm-mini-list a:hover {
  color: var(--accent);
}

.whm-placeholder {
  min-height: 280px;
}

.whm-modal {
  width: min(96vw, 1180px);
}

.whm-form-grid {
  padding: 14px 16px;
}

.whm-form-grid .field-wide {
  grid-column: span 2;
}

.whm-lot-head {
  background: var(--surface-2);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
}

.whm-lot-head strong {
  color: var(--text);
}

.whm-lot-inline {
  margin-top: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.whm-lot-inline input {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  color: var(--text);
}

.whm-product-head {
  margin-bottom: 0;
}

@media (max-width: 1200px) {
  .whm-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .whm-search {
    min-width: 220px;
  }
  .whm-form-grid .field-wide {
    grid-column: span 1;
  }
}

@media (max-width: 720px) {
  .whm-table th,
  .whm-table td {
    padding: 9px 8px;
    font-size: 12px;
  }

  .product-head {
    grid-template-columns: 1fr;
  }

  .product-kpis {
    justify-content: flex-start;
    text-align: left;
    flex-wrap: wrap;
  }

  .modal-body {
    grid-template-columns: 1fr;
  }

  .modal-left {
    border-right: 0;
    border-bottom: 1px solid var(--border-soft);
  }
}

/* ===== Document modal: footer totals (Позиций / Кол-во / Сумма) ===== */
.total-pair {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  min-width: 90px;
  margin-right: 28px;
  vertical-align: top;
  padding: 4px 0;
}
.total-pair:last-child {
  margin-right: 0;
}
.total-pair .total-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
  line-height: 1.2;
}
.total-pair .total-value {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* ===== Document modal (warehouse) — visual polish ===== */
.wh-modal {
  background: var(--surface);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35), 0 6px 18px rgba(0, 0, 0, .12);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wh-modal .modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.wh-modal .modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.wh-modal .modal-header .spacer { flex: 1; }
.wh-modal .doc-status {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.wh-modal .doc-status.posted { background: rgba(34, 197, 94, .15); color: #16a34a; }
.wh-modal .doc-status.cancelled,
.wh-modal .doc-status.canceled { background: rgba(239, 68, 68, .15); color: #dc2626; }
.wh-modal .doc-status.draft { background: var(--surface-2); color: var(--text-muted); }

.wh-modal .modal-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  flex: 1;
  min-height: 0;
  overflow: auto;
}
.wh-modal .modal-left {
  padding: 20px 24px;
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wh-modal .modal-right {
  padding: 20px 24px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.wh-modal .field { margin: 0; }
.wh-modal .field label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.wh-modal .field .input,
.wh-modal .field .select {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.wh-modal .field .input:focus,
.wh-modal .field .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.wh-modal .field textarea.input {
  resize: vertical;
  min-height: 60px;
  font-family: inherit;
}

.wh-modal .fifo-hint {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.45;
}
.wh-modal .fifo-hint .icon {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 16px;
  font-weight: 700;
}
.wh-modal .fifo-hint strong { color: var(--accent); font-weight: 700; }

.wh-modal .items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.wh-modal .items-table thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 10px 8px;
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.wh-modal .items-table thead th.num { text-align: right; }
.wh-modal .items-table tbody td {
  padding: 8px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.wh-modal .items-table tbody td.num { text-align: right; }
.wh-modal .items-table tbody tr:last-child td { border-bottom: none; }
.wh-modal .items-table tbody select,
.wh-modal .items-table tbody input {
  width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.wh-modal .items-table tbody select:focus,
.wh-modal .items-table tbody input:focus {
  outline: none;
  border-color: var(--accent);
}
.wh-modal .items-table tbody input[type="number"] { text-align: right; }
.wh-modal .items-table .whm-lot-inline {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.wh-modal .items-table .whm-lot-inline input { font-size: 12px; padding: 5px 8px; }

.wh-modal .modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}
.wh-modal .totals {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.wh-modal .modal-footer .row {
  flex: 0 0 auto;
  align-items: center;
}
.wh-modal .modal-footer .muted[data-wh-doc-error] {
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
}

/* Disabled state inside warehouse modal */
.wh-modal button:disabled,
.wh-modal button[disabled] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.wh-modal .btn-primary:disabled,
.wh-modal .btn-primary[disabled] { background: var(--surface-2); color: var(--text-muted); }

/* ===== Warehouse screens polish (home / catalog / product card) ===== */

/* --- Chip status colors (LOT badges: Просрочена / Истекает / Закрыта) --- */
.chip-danger {
  background: rgba(239, 68, 68, .15);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, .25);
}
.chip-warning {
  background: rgba(245, 158, 11, .15);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, .25);
}
.chip-accent {
  background: var(--accent-tint);
  color: var(--accent);
  border: 1px solid rgba(31, 156, 77, .25);
}

/* --- KPI: colored side stripes for visual identity --- */
.whm-kpi-grid .kpi {
  position: relative;
  padding-left: 18px;
  overflow: hidden;
}
.whm-kpi-grid .kpi::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--accent);
}
.whm-kpi-grid .kpi:nth-child(2)::before { background: #95C944; }    /* lime */
.whm-kpi-grid .kpi:nth-child(3)::before { background: #f59e0b; }    /* warning orange */
.whm-kpi-grid .kpi:nth-child(4)::before { background: #6366f1; }    /* indigo for docs */

.kpi .kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.kpi .kpi-sub.warning {
  color: #d97706;
  font-weight: 500;
}

/* --- Quick actions: tile buttons instead of inline links --- */
.whm-quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 0;
}
.whm-quick-actions a,
.whm-quick-actions button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .15s, background .15s, transform .05s;
  cursor: pointer;
  text-align: left;
}
.whm-quick-actions a:hover,
.whm-quick-actions button:hover {
  border-color: var(--accent);
  background: var(--surface);
  transform: translateY(-1px);
}
.whm-quick-actions svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  stroke-width: 1.75;
}
.whm-quick-actions a[disabled],
.whm-quick-actions button[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* --- Catalog row hover + danger row highlight --- */
.whm-table tbody tr {
  transition: background .12s;
}
.whm-table tbody tr:hover td {
  background: var(--surface-hover);
}

/* --- LOT head — clearer card-like separation --- */
.whm-lot-head {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 10px 14px;
  margin: 14px 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.whm-lot-head strong {
  font-size: 14px;
  letter-spacing: 0.01em;
}
.whm-lot-head .chip {
  font-size: 11px;
  padding: 3px 10px;
}

/* --- Alert bar danger emphasis --- */
.alert-bar.danger {
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .25);
  color: #b91c1c;
}
.alert-bar.danger .whm-alert-ico,
.alert-bar.danger .whm-alert-ico svg {
  color: #dc2626;
}

/* --- Movement directional cells (приход зелёный, расход красноватый) --- */
.col-in { color: var(--success, #16a34a); font-weight: 600; }
.col-out { color: #dc2626; font-weight: 600; }
.col-bal { color: var(--text); font-weight: 600; }

/* --- Product card: chip-accent (юр.лицо badge) --- */
.chip.mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
}


/* ===== Catalog drag & drop reordering ===== */
.whm-table th.drag-handle-col,
.whm-table td.drag-handle-col {
  width: 32px;
  padding: 6px 4px;
  text-align: center;
  vertical-align: middle;
}
.whm-table .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--text-dim);
  cursor: grab;
  user-select: none;
  border-radius: 4px;
  line-height: 1;
  transition: color .12s, background .12s;
}
.whm-table .drag-handle svg {
  width: 14px;
  height: 14px;
  pointer-events: none;
}
.whm-table tbody tr:hover .drag-handle {
  color: var(--text);
}
.whm-table .drag-handle:hover {
  color: var(--accent);
  background: var(--accent-tint);
}
.whm-table .drag-handle:active {
  cursor: grabbing;
}
.whm-table tbody tr[draggable="true"] {
  transition: opacity .12s, background .12s;
}
.whm-table tbody tr.dragging {
  opacity: 0.35;
}
.whm-table tbody tr.drag-over-above > td {
  box-shadow: inset 0 2px 0 0 var(--accent);
}
.whm-table tbody tr.drag-over-below > td {
  box-shadow: inset 0 -2px 0 0 var(--accent);
}


/* ===== Catalog column sorting ===== */
.whm-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color .12s, background .12s;
}
.whm-table th.sortable:hover {
  color: var(--accent);
  background: var(--surface-hover, var(--surface-2));
}
.whm-table th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  font-weight: 700;
}
.whm-table .drag-handle.is-disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.whm-table .drag-handle.is-disabled:hover {
  color: var(--text-dim);
  background: transparent;
}


/* ===== CRM pipelines bar ===== */
.pipelines-bar {
  margin: 0 0 12px 0;
  border-bottom: 1px solid var(--border-soft);
}
.pipelines-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  padding: 0 0 0 0;
}
.pipeline-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color .12s, background .12s, border-color .12s;
}
.pipeline-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}
.pipeline-tab.active {
  color: var(--accent);
  background: var(--surface-2);
  border-color: var(--border-soft);
  border-bottom-color: var(--surface-2);
  margin-bottom: -1px;
  font-weight: 600;
}
.pipeline-tab-new {
  color: var(--text-dim);
  border-style: dashed;
  border-color: var(--border-soft);
  margin-left: auto;
}
.pipeline-tab-new:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.pipeline-tab-new svg {
  width: 14px;
  height: 14px;
}


/* ===== Pipelines manager modal ===== */
.pipeline-tab-manage {
  padding: 8px 10px;
  color: var(--text-dim);
  border: 1px solid transparent;
}
.pipeline-tab-manage:hover {
  color: var(--accent);
  background: var(--surface-2);
}
.pipeline-tab-manage svg {
  width: 16px;
  height: 16px;
}
.pm-body {
  padding: 16px 20px;
  max-height: 70vh;
  overflow-y: auto;
}
.pm-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 8px 0;
}
.pm-section-title + .pm-section-title,
.pm-list + .pm-section-title {
  margin-top: 18px;
}
.pm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  transition: border-color .12s, background .12s;
}
.pm-row:hover {
  border-color: var(--border, var(--border-soft));
}
.pm-row.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
}
.pm-row-main {
  flex: 1;
  min-width: 0;
}
.pm-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.pm-title-deleted {
  color: var(--text-dim);
  text-decoration: line-through;
  text-decoration-color: var(--text-dim);
}
.pm-badge {
  display: inline-block;
  padding: 1px 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pm-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}
.pm-row-actions {
  display: flex;
  gap: 4px;
}
.pm-row-actions .btn-ghost.danger:not(:disabled):hover {
  color: var(--danger, #ef4444);
  background: rgba(239, 68, 68, .1);
}
.pm-row-actions button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pm-trash .pm-row {
  background: transparent;
  border-style: dashed;
}


/* ===== Deal modal: pipeline transfer row ===== */
.deal-pipeline-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px 6px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.dpr-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}
.dpr-select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  min-width: 180px;
  cursor: pointer;
}
.dpr-select:hover {
  border-color: var(--accent);
}
.dpr-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}
.dpr-hint {
  font-size: 12px;
  color: var(--text-muted);
}


/* ===== Dashboard: 13 reports ===== */
.dashboard-reports {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 20px;
  box-sizing: border-box;
  min-height: calc(100vh - 100px);
}
.dr-sidebar {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 0;
  overflow-y: auto;
  max-height: calc(100vh - 140px);
  position: sticky;
  top: 20px;
}
.dr-sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  padding: 4px 16px 12px;
}
.dr-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dr-list li { margin: 0; padding: 0; }
.dr-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background .12s, color .12s;
  position: relative;
}
.dr-item:hover { background: var(--surface); }
.dr-item.active {
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 600;
}
.dr-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.dr-item-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dr-item-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dr-item-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: 0.04em;
}
.dr-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.dr-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.dr-head-title { display: flex; flex-direction: column; gap: 4px; }
.dr-head-title h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.dr-demo-note {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
}
.dr-head-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.dr-period-switch {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 2px;
}
.dr-period {
  padding: 6px 14px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: background .12s, color .12s;
}
.dr-period:hover { color: var(--text); }
.dr-period.active {
  background: var(--surface);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.dr-range {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.dr-range input[type="date"] {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.dr-range input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}
.dr-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.dr-stat {
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
}
.dr-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.dr-stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.dr-stat-goal { background: var(--accent-tint); border-color: var(--accent); }
.dr-stat-goal-input { display: flex; align-items: center; gap: 6px; }
.dr-stat-goal input {
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  width: 100%;
  box-sizing: border-box;
  font-family: inherit;
}
.dr-stat-goal input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}
.dr-stat-unit {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  flex-shrink: 0;
}
.dr-chart-wrap {
  flex: 1;
  min-height: 360px;
  height: 420px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px;
  position: relative;
}
.dr-chart-wrap canvas {
  max-width: 100%;
  max-height: 100%;
}

@media (max-width: 960px) {
  .dashboard-reports {
    grid-template-columns: 1fr;
  }
  .dr-sidebar {
    max-height: 220px;
    position: relative;
    top: 0;
  }
  .dr-chart-wrap {
    height: 320px;
    min-height: 280px;
  }
}


/* ===== Dashboard v2: mode toggle + manager select + warn ===== */
.dr-head-title { gap: 8px; }
.dr-mode-toggle {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  padding: 2px;
  margin-top: 4px;
  width: fit-content;
}
.dr-mode {
  padding: 4px 12px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 4px;
  transition: background .12s, color .12s;
}
.dr-mode:hover { color: var(--text); }
.dr-mode.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.dr-warn {
  display: block;
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 6px;
  color: #d97706;
  font-size: 12px;
  font-weight: 500;
}
.dr-manager-select {
  padding: 6px 10px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  min-width: 160px;
  font-family: inherit;
}
.dr-manager-select:hover { border-color: var(--accent); }
.dr-manager-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-tint); }


/* ===== Dashboard v3: note/warn ===== */
.dr-note {
  font-size: 11px;
  color: var(--text-dim);
  font-style: italic;
  margin-top: 2px;
  display: inline-block;
  max-width: 600px;
}
.dr-note.dr-warn {
  display: block;
  font-style: normal;
  margin-top: 6px;
  padding: 8px 12px;
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 6px;
  color: #d97706;
  font-size: 12px;
  font-weight: 500;
}


/* ===== Dashboard Overview Mode ===== */
.dashboard-reports.overview-mode,
.dashboard-reports.detail-mode {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
  box-sizing: border-box;
}

.dr-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.dr-toolbar-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dr-toolbar-title { margin: 0; font-size: 24px; font-weight: 700; color: var(--text); }
.dr-toolbar-sub { font-size: 12px; color: var(--text-dim); }
.dr-toolbar-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

/* Overview grid */
.dr-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.dr-overview-card {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  font-family: inherit;
  color: inherit;
  position: relative;
}
.dr-overview-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
}
.dr-overview-card:active { transform: translateY(0); }

.dr-oc-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.dr-oc-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dr-oc-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.dr-oc-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.dr-oc-trend {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.dr-oc-trend.positive { color: #15803d; }
.dr-oc-trend.negative { color: #ef4444; }
.dr-spark {
  width: 100%;
  height: 56px;
  display: block;
}
.dr-oc-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
  min-height: 14px;
}
.dr-oc-goal {
  color: var(--accent);
  font-weight: 500;
}
.dr-oc-note {
  color: #d97706;
  font-style: italic;
}

/* Detail view */
.dr-back-btn {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  margin-bottom: 6px;
  width: fit-content;
}
.dr-back-btn:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--accent);
}
.dr-detail-title {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.dr-detail-title h2 { margin: 0; font-size: 22px; font-weight: 700; color: var(--text); }

@media (max-width: 700px) {
  .dr-toolbar { flex-direction: column; align-items: stretch; }
  .dr-overview-grid { grid-template-columns: 1fr; }
  .dr-oc-value { font-size: 22px; }
}


/* ===== Dashboard Drill-down Modal ===== */
.drill-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 25, 0.55);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: drillFadeIn 0.15s ease-out;
}
@keyframes drillFadeIn { from { opacity: 0; } to { opacity: 1; } }

.drill-modal {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: drillSlideUp 0.18s ease-out;
}
@keyframes drillSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.drill-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.drill-modal-head-text h3 {
  margin: 0 0 4px 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.drill-modal-sub {
  font-size: 12px;
  color: var(--text-dim);
}
.drill-modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background .12s, color .12s;
  flex-shrink: 0;
}
.drill-modal-close:hover {
  background: var(--surface);
  color: var(--text);
}
.drill-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.drill-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-soft);
}
.drill-item:last-child { border-bottom: none; }
.drill-item:hover { background: var(--surface-2); }
.drill-item-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 28px;
  text-align: center;
}
.drill-item-main {
  flex: 1;
  min-width: 0;
}
.drill-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drill-item-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.drill-assignee { color: var(--accent); font-weight: 500; }
.drill-item-right {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
  margin-left: 8px;
}
.drill-item-time { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.drill-empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .drill-modal-backdrop { padding: 0; }
  .drill-modal { max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
}


/* ===== Dashboard Combined Mode ===== */
.dashboard-reports.combined-mode {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 20px;
  box-sizing: border-box;
}
.dashboard-reports.combined-mode .dr-chart-wrap {
  flex: 1;
  height: 360px;
  min-height: 280px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 16px;
  position: relative;
}
.dashboard-reports.combined-mode .dr-chart-wrap canvas { max-width: 100%; max-height: 100%; }

/* Active section header */
.dr-active-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.dr-active-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.dr-active-title {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.dr-active-title h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.dr-active-dot {
  width: 14px !important;
  height: 14px !important;
}
.dr-active-help {
  font-size: 12px;
  color: var(--text-dim);
  font-style: italic;
}
.dr-active-help.dr-warn {
  background: rgba(245, 158, 11, .1);
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 6px;
  padding: 8px 12px;
  color: #d97706;
  font-style: normal;
  font-weight: 500;
}

/* Section title */
.dr-section-title {
  margin: 0 0 12px 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

/* Active overview card */
.dr-overview-card.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
  box-shadow: 0 0 0 1px var(--accent);
}
.dr-overview-card.is-active .dr-oc-title { color: var(--accent); }
.dr-overview-card.is-active::before {
  content: "Активен";
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

@media (max-width: 700px) {
  .dashboard-reports.combined-mode .dr-chart-wrap { height: 280px; }
}


/* === Deal Items Panel v2 (Stage 1.5) === */
.deal-items-panel {
  margin-top: 16px; padding: 16px;
  background: rgba(15, 20, 25, .35);
  border: 1px solid var(--border, #2a3550);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.deal-items-panel .dip-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
}
.deal-items-panel .dip-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px;
}
.deal-items-panel .dip-title strong { font-size: 15px; }
.deal-items-panel .dip-summary {
  color: var(--muted, #8896b3); font-size: 13px;
}
.deal-items-panel .dip-total { color: var(--text, #d4dce8); font-variant-numeric: tabular-nums; }

.dis-status-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  font-weight: 500;
}
.dis-status-badge.draft {
  background: rgba(136, 150, 179, .15); color: #8896b3;
}
.dis-status-badge.preliminary {
  background: rgba(34, 197, 94, .15); color: #22c55e;
}

.dis-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
}
.dis-banner-preliminary {
  background: rgba(34, 197, 94, .08);
  border: 1px solid rgba(34, 197, 94, .25);
}
.dis-banner-icon { font-size: 18px; }
.dis-banner-text { flex: 1; }
.dis-banner-text strong { color: #22c55e; }
.dis-banner-meta { font-size: 11px; color: var(--muted, #8896b3); margin-top: 2px; }

.dis-empty {
  padding: 16px 12px; border: 1px dashed var(--border, #2a3550);
  border-radius: 8px; color: var(--muted, #8896b3); font-size: 13px;
  text-align: center;
}
.dis-table-wrap { overflow: visible; }
.dis-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dis-table th {
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted, #8896b3);
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border, #2a3550);
}
.dis-table th.num, .dis-table td.num { text-align: right; }
.dis-table .th-product { min-width: 280px; }
.dis-table .th-qty, .dis-table .th-price, .dis-table .th-amount { width: 110px; }
.dis-table .th-stock { width: 100px; }
.dis-table .th-actions { width: 32px; }

.dis-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
  vertical-align: middle;
}
.dis-table input[type="number"] {
  width: 100%; background: var(--bg, transparent); color: inherit;
  border: 1px solid var(--border, #2a3550); border-radius: 6px;
  padding: 5px 8px; font-size: 13px; text-align: right;
}
.dis-table input[type="number"]:disabled { opacity: .6; cursor: not-allowed; }

.dis-stock { white-space: nowrap; font-size: 12px; color: var(--muted, #8896b3); }
.dis-stock.stock-low { color: #ef4444; font-weight: 500; }
.dis-stock.stock-ok { color: #22c55e; }
.dis-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Typeahead в строке */
.dis-typeahead { position: relative; }
.dis-ta-input {
  width: 100%; background: var(--bg, transparent); color: inherit;
  border: 1px solid var(--border, #2a3550); border-radius: 6px;
  padding: 6px 10px; font-size: 13px;
}
.dis-ta-input:focus { outline: 1px solid var(--accent, #22c55e); }
.dis-ta-input:disabled { opacity: .6; cursor: not-allowed; }
.dis-ta-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 100;
  max-height: 320px; overflow-y: auto;
  background: var(--bg-elevated, #0f1419);
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  margin-top: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.dis-ta-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
}
.dis-ta-item:hover { background: rgba(34, 197, 94, .1); }
.dis-ta-item:last-child { border-bottom: none; }
.dis-ta-item-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dis-ta-sku { font-size: 11px; color: var(--muted, #8896b3); }
.dis-ta-name { color: var(--text, #d4dce8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dis-ta-item-stock { font-size: 12px; color: var(--muted, #8896b3); white-space: nowrap; }
.dis-ta-empty { padding: 12px; text-align: center; color: var(--muted, #8896b3); font-size: 13px; }

.dis-actions-bar {
  display: flex; align-items: center; gap: 8px;
  padding-top: 4px;
}
.dis-actions-bar .dis-spacer { flex: 1; }

.dis-warning {
  padding: 8px 10px; font-size: 12px;
  background: rgba(245, 158, 11, .08); color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, .25); border-radius: 6px;
}

/* === Preliminary Orders View (склад) === */
.po-view { padding: 24px; max-width: 1280px; margin: 0 auto; }
.po-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.po-header h2 { margin: 0; font-size: 22px; }
.po-meta { color: var(--muted, #8896b3); font-size: 14px; }

.po-empty {
  padding: 64px 32px; text-align: center; color: var(--muted, #8896b3);
  border: 1px dashed var(--border, #2a3550); border-radius: 12px;
}
.po-empty-icon { font-size: 48px; margin-bottom: 12px; }
.po-empty-title { font-size: 16px; color: var(--text, #d4dce8); margin-bottom: 6px; }
.po-empty-text { font-size: 13px; max-width: 480px; margin: 0 auto; }

.po-list { display: flex; flex-direction: column; gap: 12px; }
.po-card {
  background: rgba(15, 20, 25, .4);
  border: 1px solid var(--border, #2a3550);
  border-radius: 10px;
  padding: 16px;
}
.po-card.has-shortage {
  border-color: rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .05);
}
.po-card-head {
  display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.po-card-title { flex: 1; min-width: 280px; }
.po-deal-link {
  font-size: 16px; font-weight: 500; color: var(--text, #d4dce8);
  text-decoration: none;
}
.po-deal-link:hover { color: #22c55e; }
.po-card-sub { font-size: 12px; color: var(--muted, #8896b3); margin-top: 4px; }
.po-card-meta { text-align: right; }
.po-card-total {
  font-size: 18px; font-weight: 500; color: #22c55e;
  font-variant-numeric: tabular-nums;
}
.po-card-date { font-size: 11px; color: var(--muted, #8896b3); margin-top: 2px; }
.po-card-by { font-size: 11px; color: var(--muted, #8896b3); }

.po-card-details { margin-top: 12px; }
.po-card-details summary {
  cursor: pointer; padding: 6px 0;
  font-size: 13px; color: var(--text, #d4dce8);
  list-style: none;
  display: flex; align-items: center; gap: 10px;
}
.po-card-details summary::-webkit-details-marker { display: none; }
.po-card-details summary::before {
  content: "▸"; transition: transform .15s ease;
  display: inline-block; color: var(--muted, #8896b3);
}
.po-card-details[open] summary::before { transform: rotate(90deg); }
.po-warning-tag {
  font-size: 11px; padding: 1px 6px; border-radius: 3px;
  background: rgba(239, 68, 68, .15); color: #ef4444;
}

.po-card-body { padding-top: 8px; }
.po-items-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.po-items-table th {
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted, #8896b3);
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border, #2a3550);
}
.po-items-table th.num, .po-items-table td.num { text-align: right; }
.po-items-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
}
.po-items-table .stock-low { color: #ef4444; font-weight: 500; }
.po-detail-empty {
  padding: 12px; text-align: center; color: var(--muted, #8896b3); font-size: 13px;
}


/* === Deal Items Panel — UI POLISH (override) === */
/* Перебиваем правила выше — без переделки логики, только размеры и пропорции. */

.deal-items-panel {
  /* было padding: 16px — на узкой колонке съедает место */
  padding: 12px;
  margin-top: 12px;
}

.deal-items-panel .dip-header {
  /* Заголовок + бейдж + summary в одну строку с переносом на маленьких ширинах */
  align-items: baseline;
  gap: 8px;
}
.deal-items-panel .dip-title {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  min-width: 0;
}
.deal-items-panel .dip-title strong {
  font-size: 14px;
  white-space: nowrap;
}
.deal-items-panel .dip-summary {
  font-size: 12px;
  white-space: nowrap;
}

/* На случай если ICONS.package где-то остался — ограничим размер SVG */
.deal-items-panel .dip-title svg {
  width: 16px; height: 16px; flex-shrink: 0;
}

/* Бейдж компактнее */
.dis-status-badge {
  padding: 1px 6px; font-size: 10px;
  white-space: nowrap;
}

/* Баннер компактнее */
.dis-banner {
  padding: 8px 10px; font-size: 12px;
  gap: 8px;
}
.dis-banner-icon { font-size: 16px; }
.dis-banner-text strong { font-size: 12px; }
.dis-banner-meta { font-size: 10px; }

/* Таблица — гибкие ширины, помещается в узкий контейнер */
.dis-table-wrap {
  /* На крайний случай — горизонтальный скролл, чтобы ничего не обрезалось */
  overflow-x: auto;
  margin: 0 -4px;  /* небольшое расширение в стороны для voздуха */
}
.dis-table {
  /* было table-fixed → теперь auto, чтобы товар сжимался */
  table-layout: auto;
  font-size: 12px;
  min-width: 100%;
}
.dis-table th, .dis-table td {
  padding: 5px 6px;
  font-size: 12px;
}
.dis-table th { font-size: 10px; }

/* Колонки: убираем фиксы, даём гибкость */
.dis-table .th-product {
  min-width: auto !important;
  width: auto;
}
.dis-table .th-stock {
  width: 70px;
  white-space: nowrap;
}
.dis-table .th-qty,
.dis-table .th-price {
  width: 70px;
}
.dis-table .th-amount {
  width: 90px;
  white-space: nowrap;
}
.dis-table .th-actions {
  width: 28px;
}

.dis-table input[type="number"] {
  padding: 4px 6px;
  font-size: 12px;
}

.dis-stock {
  font-size: 11px;
}

.dis-amount {
  font-size: 12px;
}

/* Typeahead в строке: компактнее */
.dis-ta-input {
  padding: 5px 8px;
  font-size: 12px;
}

/* Список не должен быть шире контейнера сделки */
.dis-ta-list {
  max-height: 280px;
  font-size: 12px;
}
.dis-ta-item {
  padding: 6px 10px;
  font-size: 12px;
}

/* Action bar — кнопки в одну строку */
.dis-actions-bar {
  flex-wrap: wrap;
  gap: 6px;
}

/* Кнопка удаления строки — компактнее */
.deal-items-panel .btn-icon.btn-sm {
  padding: 2px;
}
.deal-items-panel .btn-icon.btn-sm svg {
  width: 14px; height: 14px;
}


/* === Deal Items Summary (компактный блок в карточке сделки) === */
.deal-items-summary {
  margin-top: 12px;
  padding: 14px;
  background: rgba(15, 20, 25, .4);
  border: 1px solid var(--border, #2a3550);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.deal-items-summary .dis-sum-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}
.deal-items-summary .dis-sum-left {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.deal-items-summary .dis-sum-title {
  font-size: 14px;
}
.deal-items-summary .dis-sum-stats {
  font-size: 13px; color: var(--muted, #8896b3);
}
.deal-items-summary .dis-sum-stats strong {
  color: var(--text, #d4dce8);
  font-variant-numeric: tabular-nums;
}
.deal-items-summary .dis-sum-warning {
  font-size: 12px; color: #f59e0b;
  padding: 6px 8px;
  background: rgba(245, 158, 11, .08);
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 6px;
}
.deal-items-summary .dis-sum-actions {
  display: flex; justify-content: flex-end;
}

/* === Deal Items Modal (полноразмерная модалка) === */
.dim-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(2px);
  padding: 24px;
}
.dim-modal {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 14px;
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  overflow: hidden;
}
.dim-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2a3550);
  gap: 16px;
  flex-wrap: wrap;
}
.dim-header-left {
  display: flex; align-items: center; gap: 10px;
}
.dim-header-left h2 {
  margin: 0; font-size: 18px;
}
.dim-header-right {
  display: flex; align-items: center; gap: 16px;
}
.dim-stats { color: var(--muted, #8896b3); font-size: 14px; }
.dim-stats strong { color: var(--text, #d4dce8); font-variant-numeric: tabular-nums; }
.dim-header .icon-only {
  background: transparent;
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--muted, #8896b3);
}
.dim-header .icon-only:hover {
  background: rgba(239, 68, 68, .1);
  color: #ef4444;
}

.dim-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.dim-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: rgba(34, 197, 94, .08);
  border: 1px solid rgba(34, 197, 94, .25);
  border-radius: 8px;
  margin-bottom: 16px;
}
.dim-banner-icon { font-size: 22px; }
.dim-banner-text { flex: 1; }
.dim-banner-text strong { color: #22c55e; font-size: 14px; }
.dim-banner-meta { font-size: 12px; color: var(--muted, #8896b3); margin-top: 2px; }

.dim-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted, #8896b3);
  border: 1px dashed var(--border, #2a3550);
  border-radius: 10px;
}
.dim-empty-icon { font-size: 40px; margin-bottom: 12px; }
.dim-empty-title { font-size: 16px; color: var(--text, #d4dce8); margin-bottom: 6px; }
.dim-empty-text { font-size: 13px; max-width: 440px; margin: 0 auto; }

.dim-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.dim-table th {
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted, #8896b3);
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border, #2a3550);
  background: rgba(15, 20, 25, .3);
}
.dim-table th.num, .dim-table td.num { text-align: right; }
.dim-table .dim-th-product { width: auto; }
.dim-table .dim-th-stock { width: 110px; }
.dim-table .dim-th-qty, .dim-table .dim-th-price { width: 120px; }
.dim-table .dim-th-amount { width: 130px; }
.dim-table .dim-th-actions { width: 40px; }

.dim-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
  vertical-align: middle;
}
.dim-table tfoot td {
  border-bottom: none;
  border-top: 2px solid var(--border, #2a3550);
  padding-top: 12px;
  font-size: 15px;
}
.dim-table input[type="number"] {
  width: 100%;
  background: var(--bg, transparent);
  color: inherit;
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dim-table input[type="number"]:focus { outline: 1px solid #22c55e; }

.dim-stock { white-space: nowrap; font-size: 12px; color: var(--muted, #8896b3); }
.dim-stock.stock-low { color: #ef4444; font-weight: 500; }
.dim-stock.stock-ok { color: #22c55e; }
.dim-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim-total { font-variant-numeric: tabular-nums; font-size: 16px; }

/* Typeahead в строке модалки — БЕЗ обрезания (модалка не клипает) */
.dim-typeahead { position: relative; }
.dim-ta-input {
  width: 100%;
  background: var(--bg, transparent);
  color: inherit;
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
}
.dim-ta-input:focus { outline: 1px solid #22c55e; }
.dim-ta-list {
  position: absolute;
  top: calc(100% + 2px); left: 0; right: 0;
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.dim-ta-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
}
.dim-ta-item:hover { background: rgba(34, 197, 94, .12); }
.dim-ta-item:last-child { border-bottom: none; }
.dim-ta-item-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.dim-ta-sku { font-size: 11px; color: var(--muted, #8896b3); font-family: monospace; }
.dim-ta-name {
  color: var(--text, #d4dce8);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dim-ta-item-stock {
  font-size: 12px; color: var(--muted, #8896b3); white-space: nowrap;
}
.dim-ta-empty {
  padding: 16px; text-align: center;
  color: var(--muted, #8896b3); font-size: 13px;
}

.dim-warning {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(245, 158, 11, .08);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, .25);
  border-radius: 6px;
  font-size: 13px;
}

.dim-footer {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-top: 1px solid var(--border, #2a3550);
  gap: 12px;
  flex-wrap: wrap;
}
.dim-footer-right {
  display: flex; gap: 8px;
}

/* Адаптивность для маленьких экранов */
@media (max-width: 700px) {
  .dim-backdrop { padding: 0; }
  .dim-modal { max-height: 100vh; max-width: 100vw; border-radius: 0; }
  .dim-th-stock { display: none; }
  .dim-stock { display: none; }
}


/* === CRM List View === */
.crm-toolbar-divider {
  width: 1px; height: 24px;
  background: var(--border, #2a3550);
  margin: 0 4px;
}

.crm-view-toggle {
  display: inline-flex;
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.crm-vt-btn {
  background: transparent;
  border: none;
  color: var(--muted, #8896b3);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.crm-vt-btn:hover { color: var(--text, #d4dce8); }
.crm-vt-btn.active {
  background: var(--accent, #22c55e);
  color: #fff;
}
.crm-vt-label { font-size: 13px; }

/* Stages filter */
.crm-stages-filter { position: relative; }
.crm-sf-toggle {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  color: var(--text, #d4dce8);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.crm-sf-toggle:hover { border-color: var(--accent, #22c55e); }
.crm-stages-filter.open .crm-sf-toggle { border-color: var(--accent, #22c55e); }
.crm-sf-label { color: var(--muted, #8896b3); }
.crm-sf-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  z-index: 200;
  min-width: 280px;
  max-height: 400px; overflow-y: auto;
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0,0,0,.4);
  padding: 4px 0;
}
.crm-sf-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
}
.crm-sf-row:hover { background: rgba(34, 197, 94, .08); }
.crm-sf-row input { margin: 0; cursor: pointer; }
.crm-sf-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.crm-sf-divider {
  height: 1px;
  background: var(--border, #2a3550);
  margin: 4px 0;
}
.crm-sf-actions {
  display: flex; justify-content: flex-end;
  padding: 6px 10px;
  border-top: 1px solid var(--border, #2a3550);
  margin-top: 4px;
}

/* List view */
.crm-list-view {
  padding: 16px 24px;
}
.crm-list-meta {
  color: var(--muted, #8896b3);
  font-size: 13px;
  margin-bottom: 12px;
}
.crm-list-meta strong { color: var(--text, #d4dce8); }

.crm-list-table-wrap {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 10px;
  overflow: hidden;
}
.crm-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.crm-list-table th {
  text-align: left;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted, #8896b3);
  font-weight: 500;
  padding: 10px 12px;
  background: rgba(15,20,25,.4);
  border-bottom: 1px solid var(--border, #2a3550);
  white-space: nowrap;
}
.crm-list-table th.num, .crm-list-table td.num { text-align: right; }
.crm-list-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light, rgba(255,255,255,.04));
  vertical-align: middle;
}
.crm-list-table tbody tr:last-child td { border-bottom: none; }
.crm-list-table tbody tr:hover { background: rgba(34, 197, 94, .04); }
.crm-list-table tbody tr.selected { background: rgba(34, 197, 94, .08); }

.cl-th-select, .cl-td-select { width: 40px; padding-right: 0; }
.cl-th-select input, .cl-td-select input { cursor: pointer; }
.cl-th-amount { width: 130px; }
.cl-th-date { width: 110px; }
.cl-th-stage { width: 180px; }
.cl-th-assignee { width: 180px; }

.cl-deal-link {
  color: var(--text, #d4dce8);
  text-decoration: none;
  font-weight: 500;
}
.cl-deal-link:hover { color: var(--accent, #22c55e); }

.cl-stage-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.cl-assignee {
  display: inline-flex; align-items: center; gap: 6px;
}
.cl-assignee-name { font-size: 13px; }

.cl-td-amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cl-td-date { color: var(--muted, #8896b3); font-size: 12px; }

.cl-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted, #8896b3);
}

/* Pagination */
.crm-pagination {
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  margin-top: 16px;
}
.crm-pages {
  display: inline-flex; align-items: center; gap: 4px;
}
.cp-page {
  background: transparent;
  border: 1px solid var(--border, #2a3550);
  color: var(--text, #d4dce8);
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  min-width: 32px;
}
.cp-page:hover { border-color: var(--accent, #22c55e); }
.cp-page.active {
  background: var(--accent, #22c55e);
  color: #fff;
  border-color: var(--accent, #22c55e);
}
.cp-gap { color: var(--muted, #8896b3); padding: 0 4px; }

/* Mass action bar */
.crm-mass-action-bar {
  position: sticky;
  bottom: 16px;
  margin: 16px 24px 0;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--accent, #22c55e);
  border-radius: 10px;
  padding: 10px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  z-index: 50;
}
.cma-info { font-size: 14px; color: var(--text, #d4dce8); }
.cma-info strong { color: var(--accent, #22c55e); }
.cma-actions {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.cma-danger { color: #ef4444; }
.cma-danger:hover { background: rgba(239, 68, 68, .1); }

/* Mass action modal */
.cma-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 2100;
  backdrop-filter: blur(2px);
  padding: 24px;
}
.cma-modal {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 12px;
  width: 100%; max-width: 480px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}
.cma-modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border, #2a3550);
}
.cma-modal-header h2 { margin: 0; font-size: 16px; }
.cma-modal-body { padding: 20px; }
.cma-modal-body p { margin: 0 0 8px; font-size: 14px; }
.cma-modal-field { margin-bottom: 16px; }
.cma-modal-field:last-child { margin-bottom: 0; }
.cma-modal-field label {
  display: block; margin-bottom: 6px;
  font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted, #8896b3);
}
.cma-modal-field select {
  width: 100%;
  background: var(--bg, #0f1419);
  border: 1px solid var(--border, #2a3550);
  color: var(--text, #d4dce8);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.cma-modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border, #2a3550);
}
.btn-danger {
  background: #ef4444; color: #fff; border: none;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px;
}
.btn-danger:hover { background: #dc2626; }


/* === CRM List View — Light Theme Fixes === */
/* Дочерние элементы — явные цвета чтобы наследование не ломалось */

.crm-vt-btn,
.crm-sf-toggle,
.crm-sf-row,
.crm-sf-toggle strong,
.crm-sf-toggle .crm-sf-label,
.crm-sf-row span {
  color: var(--text);
}
.crm-vt-btn.active,
.crm-vt-btn.active span {
  color: #fff;
}
.crm-vt-btn:not(.active) {
  color: var(--muted);
}
.crm-vt-btn:not(.active):hover {
  color: var(--text);
}

/* В светлой теме --bg-elevated может быть белым и сливаться — добавим явный hover */
.crm-sf-toggle:hover,
.crm-stages-filter.open .crm-sf-toggle {
  background: var(--bg);
}
.crm-sf-dropdown {
  background: var(--bg-elevated);
  color: var(--text);
}
.crm-sf-row {
  color: var(--text);
}
.crm-sf-row strong { color: var(--text); }
.crm-sf-row span { color: inherit; }

/* List table в светлой теме */
.crm-list-table-wrap {
  background: var(--bg-elevated);
  color: var(--text);
}
.crm-list-table thead th {
  background: var(--bg);
  color: var(--muted);
}
.crm-list-table tbody td {
  color: var(--text);
}
.cl-deal-link {
  color: var(--text);
}
.cl-deal-link:hover { color: var(--accent); }
.cl-contact-name { color: var(--text); }
.cl-assignee-name { color: var(--text); }

/* Pagination в светлой теме */
.cp-page {
  background: var(--bg-elevated);
  color: var(--text);
}
.cp-page:hover { background: var(--bg); }
.cp-page.active {
  background: var(--accent);
  color: #fff;
}

/* Mass action bar — лучшие контрасты */
.crm-mass-action-bar {
  background: var(--bg-elevated);
  color: var(--text);
}
.cma-info { color: var(--text); }
.cma-info strong { color: var(--accent); }

/* Mass action modal в светлой теме */
.cma-modal {
  background: var(--bg-elevated);
  color: var(--text);
}
.cma-modal-header h2 { color: var(--text); }
.cma-modal-body p { color: var(--text); }
.cma-modal-field label { color: var(--muted); }
.cma-modal-field select {
  background: var(--bg);
  color: var(--text);
}

/* Toolbar divider — видимый и в свете, и в темноте */
.crm-toolbar-divider {
  background: var(--border);
}

/* Selected counter */
.cl-selected-info {
  color: var(--accent);
}

/* Disabled apply button во время операции */
[data-mass-action-apply][disabled] {
  opacity: 0.7;
  cursor: wait;
}
[data-mass-progress] {
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}


/* === Override прежних стилей: используем .crm-view-btn для всех toggle === */

/* Убираем дубликат-обёртку (она уже не рендерится но мог остаться кэш) */
.crm-view-toggle { display: contents; }

/* Сделать кнопки переключателя гладко-стыкуемыми по две (опционально) */
.crm-view-btn[data-crm-view] {
  padding: 6px 12px;
}

/* Фильтр стадий — кнопка использует .crm-view-btn, dropdown остаётся */
.crm-stages-filter {
  position: relative;
  display: inline-block;
}
.crm-sf-toggle {
  /* унаследует .crm-view-btn но добавим разделитель для метки/значения */
  white-space: nowrap;
}
.crm-sf-toggle .crm-sf-label {
  color: var(--muted);
  font-weight: 400;
}
.crm-sf-toggle strong { color: var(--text); }

/* Dropdown — обе темы */
.crm-sf-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0;
  z-index: 200;
  min-width: 280px;
  max-height: 400px; overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .2);
  padding: 4px 0;
  color: var(--text);
}
.crm-sf-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
}
.crm-sf-row * { color: inherit; }
.crm-sf-row:hover { background: rgba(34, 197, 94, .12); }
.crm-sf-divider { background: var(--border); }

/* Toolbar divider — мы его рендерим, но он не сильно нужен — скроем */
.crm-toolbar-divider { display: none; }

/* Гарантировать что .crm-view-btn виден в светлой теме как в Канбан/Звонки */
/* Полагаемся на существующие классы — никаких override background */


/* === CRM Toolbar Polish (final) === */
/* Перебиваем ВСЕ старые .crm-sf-toggle стили — кнопка прозрачная как CRM/Звонки */
.crm-sf-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  white-space: nowrap;
  font-weight: 500;
}
.crm-sf-toggle:hover {
  background: rgba(128, 128, 128, .08);
  border-color: var(--accent);
}
.crm-stages-filter.open .crm-sf-toggle {
  background: rgba(34, 197, 94, .1);
  border-color: var(--accent);
  color: var(--accent);
}
.crm-sf-toggle .crm-sf-label {
  color: var(--muted);
  font-weight: 400;
}
.crm-sf-toggle strong {
  color: var(--text);
  font-weight: 600;
}

/* === Группировка в тулбаре — flex с разделителями === */
.deals-toolbar {
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
/* Левая часть — переключатель режимов CRM/Звонки/Контакты как сегмент-группа */
.deals-toolbar > div:first-child {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: rgba(128, 128, 128, .06);
  border-radius: 10px;
}
/* Внутри сегмента кнопки чуть компактнее */
.deals-toolbar > div:first-child .crm-view-btn {
  padding: 5px 12px;
  border: none;
}
.deals-toolbar > div:first-child .crm-view-btn:not(.active):hover {
  background: rgba(128, 128, 128, .08);
}

/* Канбан / Список — отдельный сегмент с разделителем перед */
.deals-toolbar [data-crm-view] {
  margin-left: 0;
}
.deals-toolbar [data-crm-view]:first-of-type {
  margin-left: 8px;
  position: relative;
}
.deals-toolbar [data-crm-view]:first-of-type::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 4px; bottom: 4px;
  width: 1px;
  background: var(--border);
}

/* Кнопка "+ Сделка" не убегает за край viewport */
.deals-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}


/* === REVERT агрессивных toolbar стилей из CRM_UI_POLISH === */
/* Отменяем сегмент-обёртку которая ломала layout и сжимала поиск */
.deals-toolbar > div:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.deals-toolbar > div:first-child::before { display: none; }
.deals-toolbar > div:first-child .crm-view-btn {
  /* возврат к дефолту .crm-view-btn — никаких override */
  padding: 6px 12px;
  border: 1px solid var(--border);
}
.deals-toolbar [data-crm-view]:first-of-type {
  margin-left: 0;
}
.deals-toolbar [data-crm-view]:first-of-type::before {
  display: none;
}

/* Toolbar остаётся как flex с обычным gap */
.deals-toolbar {
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Лёгкий разделитель между группами через margin */
.crm-stages-filter {
  margin-left: 4px;
}


/* === FINAL TOOLBAR CLEANUP — nuke все мои предыдущие сломанные override === */
.deals-toolbar > div:first-child {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}
.crm-toolbar-divider,
.deals-toolbar > div:first-child::before,
.deals-toolbar [data-crm-view]:first-of-type::before {
  display: none !important;
  content: none !important;
}
.deals-toolbar [data-crm-view]:first-of-type {
  margin-left: 0 !important;
}

/* === Новый контейнер для Канбан/Список/Стадии — рядом с .crm-view-switch === */
.crm-view-tools {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  flex-wrap: wrap;
}
.crm-view-tools .crm-view-btn {
  padding: 6px 12px;
}

/* === Стадии: прозрачная кнопка, единый стиль === */
.crm-sf-toggle {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  padding: 6px 12px !important;
  border-radius: 8px !important;
  font-size: 13px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  white-space: nowrap !important;
  font-weight: 500 !important;
}
.crm-sf-toggle:hover {
  background: rgba(128, 128, 128, .08) !important;
  border-color: var(--accent) !important;
}
.crm-stages-filter.open .crm-sf-toggle {
  background: rgba(34, 197, 94, .1) !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.crm-sf-toggle .crm-sf-label {
  color: var(--muted) !important;
  font-weight: 400 !important;
}
.crm-sf-toggle strong {
  color: var(--text) !important;
  font-weight: 600 !important;
}


/* === FORCE HORIZONTAL TOOLBAR (final) === */
/* Все накопленные правила пытались всё расположить по-разному —
   перебиваем агрессивно один раз на всё. */

.deals-toolbar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  flex-wrap: wrap !important;
  padding: 12px 24px !important;
}

.crm-top-controls {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
}

.crm-view-switch {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 4px !important;
  flex-shrink: 0 !important;
  width: auto !important;
  flex-wrap: nowrap !important;
}

.crm-view-tools {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0 !important;
  flex-wrap: nowrap !important;
  margin-left: 0 !important;
}

.crm-global-search {
  display: inline-flex !important;
  flex: 1 1 280px !important;
  min-width: 200px !important;
  margin: 0 !important;
}

.deals-toolbar-right {
  display: inline-flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}

/* Воронки сверху — тоже выровнять слева */
.crm-pipelines-bar,
.pipelines-bar {
  justify-content: flex-start !important;
}


/* === TOOLBAR CLARITY — визуальное разделение по назначению === */

/* === ГРУППА 1: РАЗДЕЛ — Сегмент-плашка с серым фоном === */
/* CRM / Звонки / Контакты — переключение основных разделов */
.crm-view-switch {
  display: inline-flex !important;
  align-items: center !important;
  background: rgba(128, 128, 128, .08) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 3px !important;
  gap: 2px !important;
  flex-shrink: 0 !important;
}
.crm-view-switch .crm-view-btn {
  background: transparent !important;
  border: none !important;
  border-radius: 7px !important;
  padding: 6px 14px !important;
  color: var(--muted) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
}
.crm-view-switch .crm-view-btn:hover {
  color: var(--text) !important;
  background: rgba(128, 128, 128, .06) !important;
}
.crm-view-switch .crm-view-btn.active {
  background: var(--bg-elevated) !important;
  color: var(--accent) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 1px rgba(0, 0, 0, .04) !important;
}

/* === ГРУППА 2: ВИД — Меньшая сегмент-плашка === */
/* Канбан / Список — переключение отображения данных */
.crm-view-tools {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
  flex-wrap: nowrap !important;
  margin-left: 8px !important;
}
.crm-view-tools [data-crm-view] {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--muted) !important;
  padding: 5px 10px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
}
.crm-view-tools [data-crm-view]:first-of-type {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right-width: 0 !important;
}
.crm-view-tools [data-crm-view]:nth-of-type(2) {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.crm-view-tools [data-crm-view]:hover {
  color: var(--text) !important;
  background: rgba(128, 128, 128, .06) !important;
}
.crm-view-tools [data-crm-view].active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}
.crm-view-tools [data-crm-view].active + [data-crm-view] {
  border-left-color: var(--accent) !important;
}

/* === ГРУППА 3: ФИЛЬТР — Dashed-кнопка с явным значком ▾ === */
/* Стадии — фильтр по стадиям */
.crm-sf-toggle {
  background: transparent !important;
  border: 1px dashed var(--border) !important;
  color: var(--text) !important;
  padding: 5px 10px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  white-space: nowrap !important;
}
.crm-sf-toggle:hover {
  background: rgba(128, 128, 128, .06) !important;
  border-style: solid !important;
  border-color: var(--accent) !important;
}
.crm-stages-filter.open .crm-sf-toggle {
  background: rgba(34, 197, 94, .1) !important;
  border-style: solid !important;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
}
.crm-sf-toggle .crm-sf-label {
  color: var(--muted) !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: .04em !important;
  font-weight: 500 !important;
}
.crm-sf-toggle strong {
  color: var(--text) !important;
  font-weight: 600 !important;
  font-size: 12px !important;
}

/* === ГРУППА 4: ПОИСК — серый input field === */
.crm-global-search {
  display: inline-flex !important;
  align-items: center !important;
  flex: 1 1 240px !important;
  min-width: 200px !important;
  max-width: 480px !important;
  background: rgba(128, 128, 128, .06) !important;
  border: 1px solid var(--border) !important;
  border-radius: 8px !important;
  padding: 0 12px !important;
  gap: 6px !important;
  margin: 0 8px 0 0 !important;
  height: 36px !important;
}
.crm-global-search input {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  flex: 1 !important;
  color: var(--text) !important;
  font-size: 13px !important;
  height: 100% !important;
  padding: 0 !important;
}
.crm-search-icon {
  color: var(--muted) !important;
  display: inline-flex !important;
  align-items: center !important;
}

/* === ОБЩИЙ КОНТЕЙНЕР === */
.deals-toolbar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  flex-wrap: wrap !important;
  padding: 16px 24px !important;
}
.crm-top-controls {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.deals-toolbar-right {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}


/* =================================================================
   PLLATO TOOLBAR — финальный чистый дизайн
   Все стили скоупнуты под .pllato-toolbar чтобы не пересекаться
   со старыми CSS правилами накопленными в файле.
   ================================================================= */

.pllato-toolbar {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 24px;
}

.pllato-toolbar .crm-top-controls {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}

.pllato-toolbar .deals-toolbar-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}

/* === Сегменты (плашка с фоном для группы связанных кнопок) === */
.pllato-toolbar .pllato-tabs,
.pllato-toolbar .pllato-tools {
  display: inline-flex;
  align-items: center;
  background: rgba(128, 128, 128, .07);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
  flex-shrink: 0;
}

/* Кнопки внутри любого сегмента: единый базовый стиль */
.pllato-toolbar .pllato-tabs .crm-view-btn,
.pllato-toolbar .pllato-tools [data-crm-view] {
  background: transparent;
  border: none;
  border-radius: 7px;
  padding: 6px 14px;
  color: var(--muted);
  font-weight: 500;
  font-size: 13px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, color .12s;
}
.pllato-toolbar .pllato-tabs .crm-view-btn:hover,
.pllato-toolbar .pllato-tools [data-crm-view]:hover {
  color: var(--text);
  background: rgba(128, 128, 128, .08);
}

/* Активная кнопка в сегменте — "вынутая" наверх */
.pllato-toolbar .pllato-tabs .crm-view-btn.active,
.pllato-toolbar .pllato-tools [data-crm-view].active {
  background: var(--bg-elevated);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 1px rgba(0, 0, 0, .04);
}

/* Размеры — переключатель раздела чуть крупнее чем переключатель вида */
.pllato-toolbar .pllato-tools [data-crm-view] {
  padding: 5px 10px;
  font-size: 12px;
}

/* === Стадии: фильтр-кнопка вне сегмента, отдельная === */
.pllato-toolbar .crm-stages-filter { position: relative; }
.pllato-toolbar .crm-sf-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-weight: 500;
  transition: border-color .12s, background .12s;
}
.pllato-toolbar .crm-sf-toggle:hover {
  border-color: var(--accent);
  background: rgba(128, 128, 128, .06);
}
.pllato-toolbar .crm-stages-filter.open .crm-sf-toggle {
  background: rgba(34, 197, 94, .08);
  border-color: var(--accent);
  color: var(--accent);
}
.pllato-toolbar .crm-sf-toggle .crm-sf-label {
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pllato-toolbar .crm-sf-toggle strong {
  color: var(--text);
  font-weight: 600;
}

/* Стадии — поскольку Стадии внутри pllato-tools (мы оба отрендерили туда),
   нужно вернуть ей нормальный стиль без сегмент-фона */
.pllato-toolbar .pllato-tools .crm-stages-filter {
  margin-left: 8px;
  background: transparent;
  padding: 0;
}

/* === Поиск === */
.pllato-toolbar .pllato-search {
  display: inline-flex;
  align-items: center;
  flex: 1 1 240px;
  min-width: 200px;
  max-width: 480px;
  background: rgba(128, 128, 128, .06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  gap: 8px;
  height: 36px;
  transition: border-color .12s, background .12s;
}
.pllato-toolbar .pllato-search:focus-within {
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.pllato-toolbar .pllato-search input {
  background: transparent;
  border: none;
  outline: none;
  flex: 1;
  color: var(--text);
  font-size: 13px;
  height: 100%;
  padding: 0;
}
.pllato-toolbar .pllato-search input::placeholder {
  color: var(--muted);
}
.pllato-toolbar .pllato-search .crm-search-icon {
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}


/* ========================================================================
   DESIGN FINAL — финальный дизайн тулбара CRM
   Все правила через html body .pllato-toolbar чтобы гарантированно
   перебить накопленные за 8 итераций override'ы.
   ======================================================================== */

/* === Контейнер: flex-row с воздухом === */
html body .pllato-toolbar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding: 14px 24px !important;
  background: transparent !important;
}

html body .pllato-toolbar .crm-top-controls {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  border: none !important;
}

html body .pllato-toolbar .deals-toolbar-right {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  flex-shrink: 0 !important;
  margin-left: auto !important;
}

/* === ГРУППА: переключатель РАЗДЕЛОВ (CRM/Звонки/Контакты) === */
html body .pllato-toolbar .pllato-tabs {
  display: inline-flex !important;
  align-items: center !important;
  background: rgba(127, 127, 127, .1) !important;
  border: 1px solid rgba(127, 127, 127, .15) !important;
  border-radius: 10px !important;
  padding: 3px !important;
  gap: 2px !important;
  flex-shrink: 0 !important;
}
html body .pllato-toolbar .pllato-tabs .crm-view-btn {
  background: transparent !important;
  border: none !important;
  border-radius: 7px !important;
  padding: 7px 14px !important;
  color: var(--muted, #6b7280) !important;
  font-weight: 500 !important;
  font-size: 13px !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  white-space: nowrap !important;
  transition: background .15s, color .15s !important;
  box-shadow: none !important;
}
html body .pllato-toolbar .pllato-tabs .crm-view-btn:hover {
  color: var(--text, #1f2937) !important;
  background: rgba(127, 127, 127, .08) !important;
}
html body .pllato-toolbar .pllato-tabs .crm-view-btn.active {
  background: var(--bg-elevated, #ffffff) !important;
  color: var(--accent, #22c55e) !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 1px rgba(0, 0, 0, .04) !important;
}

/* === ГРУППА: переключатель ВИДА (Канбан/Список) === */
html body .pllato-toolbar .pllato-tools {
  display: inline-flex !important;
  align-items: center !important;
  gap: 10px !important;
  flex-shrink: 0 !important;
  flex-wrap: nowrap !important;
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
}

html body .pllato-toolbar .pllato-tools [data-crm-view] {
  background: rgba(127, 127, 127, .08) !important;
  border: 1px solid rgba(127, 127, 127, .15) !important;
  color: var(--muted, #6b7280) !important;
  padding: 6px 12px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  transition: all .15s !important;
}
html body .pllato-toolbar .pllato-tools [data-crm-view]:hover {
  color: var(--text, #1f2937) !important;
  background: rgba(127, 127, 127, .12) !important;
}
html body .pllato-toolbar .pllato-tools [data-crm-view].active {
  background: var(--accent, #22c55e) !important;
  color: #ffffff !important;
  border-color: var(--accent, #22c55e) !important;
  box-shadow: 0 1px 3px rgba(34, 197, 94, .2) !important;
}

/* Канбан и Список — соединить вместе */
html body .pllato-toolbar .pllato-tools [data-crm-view="kanban"] {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  margin-right: -1px !important;
}
html body .pllato-toolbar .pllato-tools [data-crm-view="list"] {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}

/* === ГРУППА: ФИЛЬТР (Стадии: ...) === */
html body .pllato-toolbar .crm-stages-filter {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
}

html body .pllato-toolbar .crm-sf-toggle {
  background: rgba(127, 127, 127, .08) !important;
  border: 1px solid rgba(127, 127, 127, .15) !important;
  color: var(--text, #1f2937) !important;
  padding: 6px 12px !important;
  border-radius: 7px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  white-space: nowrap !important;
  transition: all .15s !important;
  box-shadow: none !important;
}
html body .pllato-toolbar .crm-sf-toggle:hover {
  background: rgba(127, 127, 127, .12) !important;
  border-color: rgba(34, 197, 94, .4) !important;
}
html body .pllato-toolbar .crm-stages-filter.open .crm-sf-toggle {
  background: rgba(34, 197, 94, .12) !important;
  border-color: var(--accent, #22c55e) !important;
  color: var(--accent, #22c55e) !important;
}
html body .pllato-toolbar .crm-sf-toggle .crm-sf-label {
  color: var(--muted, #6b7280) !important;
  font-size: 11px !important;
  text-transform: uppercase !important;
  letter-spacing: .04em !important;
  font-weight: 500 !important;
}
html body .pllato-toolbar .crm-sf-toggle strong {
  color: inherit !important;
  font-weight: 600 !important;
}

/* === ВАЖНО: непрозрачный dropdown фильтра === */
html body .pllato-toolbar .crm-sf-dropdown {
  position: absolute !important;
  top: calc(100% + 6px) !important;
  left: 0 !important;
  min-width: 260px !important;
  max-height: 400px !important;
  overflow-y: auto !important;
  background: var(--bg-elevated, #ffffff) !important;
  color: var(--text, #1f2937) !important;
  border: 1px solid rgba(127, 127, 127, .2) !important;
  border-radius: 10px !important;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18), 0 2px 6px rgba(0, 0, 0, .08) !important;
  padding: 6px 0 !important;
  z-index: 1000 !important;
}

@media (prefers-color-scheme: dark) {
  html body .pllato-toolbar .crm-sf-dropdown {
    background: #1a1f2e !important;
    color: #e5e7eb !important;
    border-color: rgba(255, 255, 255, .12) !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, .5) !important;
  }
}

html body .pllato-toolbar .crm-sf-dropdown .crm-sf-row {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 14px !important;
  cursor: pointer !important;
  font-size: 13px !important;
  color: inherit !important;
  background: transparent !important;
}
html body .pllato-toolbar .crm-sf-dropdown .crm-sf-row:hover {
  background: rgba(34, 197, 94, .08) !important;
}
html body .pllato-toolbar .crm-sf-dropdown .crm-sf-row * {
  color: inherit !important;
}
html body .pllato-toolbar .crm-sf-dropdown .crm-sf-divider {
  height: 1px !important;
  background: rgba(127, 127, 127, .15) !important;
  margin: 4px 0 !important;
}
html body .pllato-toolbar .crm-sf-dropdown .crm-sf-actions {
  padding: 6px 10px !important;
  border-top: 1px solid rgba(127, 127, 127, .15) !important;
  display: flex !important;
  justify-content: flex-end !important;
}
html body .pllato-toolbar .crm-sf-dropdown .crm-sf-dot {
  display: inline-block !important;
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  flex-shrink: 0 !important;
}

/* === ГРУППА: ПОИСК === */
html body .pllato-toolbar .pllato-search {
  display: inline-flex !important;
  align-items: center !important;
  flex: 1 1 240px !important;
  min-width: 200px !important;
  max-width: 480px !important;
  background: rgba(127, 127, 127, .06) !important;
  border: 1px solid rgba(127, 127, 127, .15) !important;
  border-radius: 8px !important;
  padding: 0 12px !important;
  gap: 8px !important;
  height: 36px !important;
  margin: 0 !important;
  transition: border-color .15s, background .15s !important;
}
html body .pllato-toolbar .pllato-search:focus-within {
  border-color: var(--accent, #22c55e) !important;
  background: var(--bg-elevated, #ffffff) !important;
}
html body .pllato-toolbar .pllato-search input {
  background: transparent !important;
  border: none !important;
  outline: none !important;
  flex: 1 !important;
  color: var(--text, #1f2937) !important;
  font-size: 13px !important;
  height: 100% !important;
  padding: 0 !important;
  font-family: inherit !important;
}
html body .pllato-toolbar .pllato-search input::placeholder {
  color: var(--muted, #9ca3af) !important;
}
html body .pllato-toolbar .pllato-search .crm-search-icon {
  color: var(--muted, #9ca3af) !important;
  display: inline-flex !important;
  align-items: center !important;
  flex-shrink: 0 !important;
}
html body .pllato-toolbar .pllato-search .crm-search-clear {
  background: transparent !important;
  border: none !important;
  color: var(--muted, #9ca3af) !important;
  cursor: pointer !important;
  padding: 4px !important;
  border-radius: 4px !important;
  display: inline-flex !important;
}
html body .pllato-toolbar .pllato-search .crm-search-clear:hover {
  background: rgba(127, 127, 127, .1) !important;
  color: #ef4444 !important;
}

/* === Скрыть устаревшие декорации от прошлых паков === */
html body .pllato-toolbar .crm-toolbar-divider { display: none !important; }
html body .pllato-toolbar .crm-view-toggle { display: contents !important; }



/* === Fix размера SVG-иконки лупы в поиске === */
html body .pllato-toolbar .pllato-search .crm-search-icon {
  width: 16px !important;
  height: 16px !important;
  flex-shrink: 0 !important;
}
html body .pllato-toolbar .pllato-search .crm-search-icon svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
}
html body .pllato-toolbar .pllato-search .crm-search-clear svg {
  width: 14px !important;
  height: 14px !important;
}


/* === Поиск: классический layout с абсолютной иконкой === */
html body .pllato-toolbar .pllato-search {
  position: relative !important;
  display: inline-block !important;
  flex: 1 1 240px !important;
  min-width: 200px !important;
  max-width: 480px !important;
  height: 36px !important;
  padding: 0 !important;
  margin: 0 !important;
  background: rgba(127, 127, 127, .06) !important;
  border: 1px solid rgba(127, 127, 127, .15) !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

html body .pllato-toolbar .pllato-search .crm-search-icon {
  position: absolute !important;
  left: 12px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 16px !important;
  height: 16px !important;
  color: var(--muted, #9ca3af) !important;
  pointer-events: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
}
html body .pllato-toolbar .pllato-search .crm-search-icon svg {
  width: 16px !important;
  height: 16px !important;
  display: block !important;
}

html body .pllato-toolbar .pllato-search input {
  width: 100% !important;
  height: 100% !important;
  background: transparent !important;
  border: none !important;
  outline: none !important;
  padding: 0 36px 0 36px !important;  /* слева для иконки, справа для clear */
  margin: 0 !important;
  color: var(--text, #1f2937) !important;
  font-size: 13px !important;
  font-family: inherit !important;
  box-sizing: border-box !important;
}
html body .pllato-toolbar .pllato-search input::placeholder {
  color: var(--muted, #9ca3af) !important;
}

html body .pllato-toolbar .pllato-search .crm-search-clear {
  position: absolute !important;
  right: 6px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  background: transparent !important;
  border: none !important;
  color: var(--muted, #9ca3af) !important;
  cursor: pointer !important;
  padding: 4px !important;
  border-radius: 4px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 24px !important;
  height: 24px !important;
}
html body .pllato-toolbar .pllato-search .crm-search-clear svg {
  width: 14px !important;
  height: 14px !important;
}
html body .pllato-toolbar .pllato-search .crm-search-clear:hover {
  background: rgba(127, 127, 127, .12) !important;
  color: #ef4444 !important;
}

html body .pllato-toolbar .pllato-search:focus-within {
  border-color: var(--accent, #22c55e) !important;
  background: var(--bg-elevated, #ffffff) !important;
}


/* === UTM Section (форма сделки) === */
.utm-section {
  margin-top: 16px;
  padding: 14px;
  background: rgba(127, 127, 127, .04);
  border: 1px solid var(--border, #2a3550);
  border-radius: 10px;
  display: flex; flex-direction: column; gap: 12px;
}
.utm-section-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px;
}
.utm-section-header strong { font-size: 14px; }
.utm-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.utm-grid .field { margin: 0; }
.utm-grid .field span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted, #8896b3);
  display: block;
  margin-bottom: 4px;
}
.utm-grid input, .utm-grid select {
  width: 100%;
  padding: 6px 10px;
  background: var(--bg, transparent);
  color: var(--text, inherit);
  border: 1px solid var(--border, #2a3550);
  border-radius: 6px;
  font-size: 13px;
}

.utm-meta {
  font-size: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border, #2a3550);
}
.utm-meta summary {
  cursor: pointer;
  color: var(--muted, #8896b3);
  padding: 4px 0;
}
.utm-meta-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}
.utm-meta-label {
  color: var(--muted, #8896b3);
  min-width: 130px;
}

/* === UTM Badge (компактный бейдж источника) === */
.utm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}
.utm-badge-icon {
  font-size: 11px;
  line-height: 1;
}
.utm-badge-text {
  font-size: 11px;
}

/* Бейдж в kanban-карточке — без переноса */
.deal-card-meta .utm-badge {
  margin-left: 6px;
}

/* Колонка Источник в списке */
.cl-th-source { width: 140px; }
.cl-td-source { white-space: nowrap; }


/* === UTM Report Modal === */
.utm-rep-backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: center; justify-content: center;
  z-index: 2200;
  backdrop-filter: blur(2px);
  padding: 24px;
}
.utm-rep-modal {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, #2a3550);
  border-radius: 14px;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  overflow: hidden;
  color: var(--text, #d4dce8);
}
@media (prefers-color-scheme: light) {
  .utm-rep-modal {
    background: #ffffff;
    color: #1f2937;
    border-color: rgba(0,0,0,.12);
  }
}
.utm-rep-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, rgba(127,127,127,.2));
}
.utm-rep-title { font-size: 18px; display: flex; align-items: center; gap: 10px; }
.utm-rep-title strong { font-size: 18px; }

.utm-rep-controls {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, rgba(127,127,127,.2));
  background: rgba(127, 127, 127, .04);
  flex-wrap: wrap;
}
.utm-rep-control-group { display: flex; flex-direction: column; gap: 6px; }
.utm-rep-control-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3);
}
.utm-rep-control-row {
  display: flex; gap: 2px;
  background: rgba(127, 127, 127, .1);
  padding: 3px; border-radius: 8px;
}
.utm-rep-period-btn, .utm-rep-dim-btn {
  background: transparent; border: none;
  padding: 5px 12px; border-radius: 6px;
  color: var(--muted, #8896b3); cursor: pointer;
  font-size: 12px; font-weight: 500;
  transition: all .15s;
}
.utm-rep-period-btn:hover, .utm-rep-dim-btn:hover { color: var(--text, #d4dce8); }
.utm-rep-period-btn.active, .utm-rep-dim-btn.active {
  background: var(--bg-elevated, #131922);
  color: var(--accent, #22c55e);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.utm-rep-control-spacer { flex: 1; }

.utm-rep-body {
  flex: 1; overflow-y: auto;
  padding: 24px;
}

.utm-rep-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.utm-rep-kpi {
  background: rgba(127, 127, 127, .06);
  border: 1px solid rgba(127, 127, 127, .15);
  border-radius: 10px;
  padding: 14px 16px;
}
.utm-rep-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted, #8896b3);
  margin-bottom: 6px;
}
.utm-rep-kpi-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text, inherit);
  font-variant-numeric: tabular-nums;
}

.utm-rep-section { margin-bottom: 28px; }
.utm-rep-section h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text, inherit);
}

/* Bars */
.utm-rep-bars { display: flex; flex-direction: column; gap: 8px; }
.utm-rep-bar-row {
  display: grid;
  grid-template-columns: 180px 1fr 140px;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.utm-rep-bar-label {
  display: flex; align-items: center; gap: 6px;
  overflow: hidden;
}
.utm-bar-icon { font-size: 14px; }
.utm-bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.utm-rep-bar-track {
  height: 22px;
  background: rgba(127, 127, 127, .08);
  border-radius: 4px;
  overflow: hidden;
}
.utm-rep-bar-fill {
  height: 100%;
  transition: width .3s ease;
  border-radius: 4px;
  opacity: .85;
}
.utm-rep-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  white-space: nowrap;
}

/* Table */
.utm-rep-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.utm-rep-table th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted, #8896b3);
  border-bottom: 1px solid rgba(127, 127, 127, .2);
  background: rgba(127, 127, 127, .04);
}
.utm-rep-table th.num, .utm-rep-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.utm-rep-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(127, 127, 127, .08);
}
.utm-rep-table tbody tr:hover { background: rgba(34, 197, 94, .04); }
.utm-rep-row-label { display: inline-flex; align-items: center; gap: 8px; }
.utm-rep-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.utm-rep-row-key {
  font-size: 11px; color: var(--muted, #8896b3);
  font-family: monospace;
}
.utm-rep-untagged em { color: var(--muted, #8896b3); }

.utm-rep-empty {
  padding: 40px;
  text-align: center;
  color: var(--muted, #8896b3);
  border: 1px dashed rgba(127, 127, 127, .25);
  border-radius: 10px;
}

/* UTM фильтр в toolbar — наследует стили stages-filter */
.crm-utm-filter { margin-left: 0; }


/* === UTM Dashboard Block — общая рамка === */
.utm-dashboard-block {
  margin-top: 32px;
  display: flex; flex-direction: column;
  gap: 20px;
}

/* === Analytics ===*/
.utm-analytics {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, rgba(127,127,127,.2));
  border-radius: 14px;
  padding: 20px 24px;
}
.utm-block-controls {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(127,127,127,.12);
  margin-bottom: 16px;
}
.utm-block-controls-left h4 { margin: 0 0 4px; font-size: 16px; }
.utm-block-sub { font-size: 12px; color: var(--muted, #8896b3); }
.utm-block-controls-right { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.utm-block-segmented {
  display: inline-flex; gap: 2px;
  background: rgba(127,127,127,.08); padding: 3px; border-radius: 7px;
}
.utm-block-period, .utm-block-dim {
  background: transparent; border: none; padding: 5px 12px; border-radius: 5px;
  color: var(--muted, #8896b3); cursor: pointer; font-size: 12px; font-weight: 500;
}
.utm-block-period:hover, .utm-block-dim:hover { color: var(--text, inherit); }
.utm-block-period.active, .utm-block-dim.active {
  background: var(--bg-elevated, #131922);
  color: var(--accent, #22c55e); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
}

.utm-block-kpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin-bottom: 20px;
}
.utm-block-kpi {
  background: rgba(127,127,127,.06); border: 1px solid rgba(127,127,127,.12);
  border-radius: 10px; padding: 12px 14px;
}
.utm-block-kpi-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3); margin-bottom: 4px;
}
.utm-block-kpi-value { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }

.utm-block-section { margin-bottom: 20px; }
.utm-block-section h5 { font-size: 13px; font-weight: 600; margin: 0 0 10px; }

.utm-block-bars { display: flex; flex-direction: column; gap: 6px; }
.utm-block-bar-row {
  display: grid; grid-template-columns: 160px 1fr 130px;
  align-items: center; gap: 12px; font-size: 12px;
}
.utm-block-bar-label { display: flex; align-items: center; gap: 6px; overflow: hidden; }
.utm-block-bar-track {
  height: 20px; background: rgba(127,127,127,.08);
  border-radius: 4px; overflow: hidden;
}
.utm-block-bar-fill { height: 100%; opacity: .85; border-radius: 4px; transition: width .3s ease; }
.utm-block-bar-value { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }

.utm-block-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.utm-block-table th {
  text-align: left; padding: 8px 10px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3);
  border-bottom: 1px solid rgba(127,127,127,.15);
  background: rgba(127,127,127,.03);
}
.utm-block-table th.num, .utm-block-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.utm-block-table td { padding: 8px 10px; border-bottom: 1px solid rgba(127,127,127,.08); }
.utm-block-table tr:hover td { background: rgba(34,197,94,.04); }
.utm-block-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.utm-block-key { font-size: 10px; color: var(--muted, #8896b3); font-family: monospace; margin-left: 6px; }
.utm-block-untagged em { color: var(--muted, #8896b3); }
.utm-block-empty {
  padding: 24px; text-align: center; color: var(--muted, #8896b3);
  border: 1px dashed rgba(127,127,127,.25); border-radius: 8px;
}

/* === Builder === */
.utm-builder {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, rgba(127,127,127,.2));
  border-radius: 14px;
  padding: 20px 24px;
}
.utm-builder-header { margin-bottom: 16px; }
.utm-builder-header h4 { margin: 0 0 4px; font-size: 16px; }
.utm-builder-sub { font-size: 12px; color: var(--muted, #8896b3); }

.utm-builder-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px;
  margin-bottom: 16px;
}
.utm-builder-field-wide { grid-column: 1 / -1; }
.utm-builder-field { display: flex; flex-direction: column; gap: 4px; }
.utm-builder-field span {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3);
}
.utm-builder-field input {
  padding: 8px 12px;
  background: rgba(127,127,127,.06);
  color: var(--text, inherit);
  border: 1px solid rgba(127,127,127,.15);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
}
.utm-builder-field input:focus {
  outline: none; border-color: var(--accent, #22c55e);
  background: var(--bg-elevated, #131922);
}

.utm-builder-preview {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.utm-builder-preview-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3); margin-bottom: 6px;
}
.utm-builder-preview-url {
  display: block; padding: 10px 12px;
  background: rgba(0,0,0,.15);
  border-radius: 6px;
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
  color: var(--accent, #22c55e);
  margin-bottom: 12px;
}
.utm-builder-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.utm-builder-history h5 { font-size: 13px; margin: 0 0 10px; }
.utm-builder-history-empty {
  padding: 16px; text-align: center;
  color: var(--muted, #8896b3); font-size: 12px;
  border: 1px dashed rgba(127,127,127,.2); border-radius: 8px;
}
.utm-builder-history-list { display: flex; flex-direction: column; gap: 8px; }
.utm-builder-history-item {
  background: rgba(127,127,127,.04);
  border: 1px solid rgba(127,127,127,.12);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.utm-builder-history-meta {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 12px;
}
.utm-builder-history-source {
  font-size: 11px; color: var(--muted, #8896b3);
}
.utm-builder-history-date {
  margin-left: auto;
  font-size: 11px; color: var(--muted, #8896b3);
}
.utm-builder-history-url code {
  font-family: 'SF Mono', Monaco, Consolas, monospace;
  font-size: 11px; word-break: break-all;
  color: var(--muted, #8896b3);
}
.utm-builder-history-actions { display: flex; gap: 4px; justify-content: flex-end; }

.btn-sm { padding: 4px 8px; font-size: 11px; }

/* Light theme override */
@media (prefers-color-scheme: light) {
  .utm-analytics, .utm-builder {
    background: #ffffff; color: #1f2937;
    border-color: rgba(0,0,0,.08);
  }
  .utm-builder-preview-url { background: rgba(0,0,0,.04); }
}


/* === Login Overlay === */
.login-overlay {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, rgba(15, 20, 25, .96) 0%, rgba(31, 156, 77, .12) 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 99999;
  padding: 20px;
  backdrop-filter: blur(8px);
}
.login-card {
  background: var(--bg-elevated, #131922);
  border: 1px solid var(--border, rgba(127,127,127,.2));
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
  color: var(--text, #d4dce8);
}
@media (prefers-color-scheme: light) {
  .login-card {
    background: #ffffff;
    color: #1f2937;
    border-color: rgba(0,0,0,.08);
  }
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { width: 56px; height: 56px; margin: 0 auto 12px; display: block; }
.login-brand h1 { font-size: 22px; margin: 0 0 4px; }
.login-sub { font-size: 13px; color: var(--muted, #8896b3); margin: 0; }
.login-warn {
  background: rgba(249, 115, 22, .1);
  border: 1px solid rgba(249, 115, 22, .3);
  border-radius: 8px;
  padding: 10px 12px; margin-bottom: 16px;
  font-size: 12px; line-height: 1.5;
  color: #f97316;
}
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-field { display: flex; flex-direction: column; gap: 4px; }
.login-field span {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted, #8896b3);
}
.login-field input {
  padding: 10px 12px;
  background: rgba(127,127,127,.06);
  border: 1px solid rgba(127,127,127,.15);
  border-radius: 8px;
  color: var(--text, inherit);
  font-size: 14px; font-family: inherit;
}
.login-field input:focus {
  outline: none; border-color: var(--accent, #22c55e);
  background: rgba(34, 197, 94, .04);
}
.login-error {
  background: rgba(239, 68, 68, .1);
  border: 1px solid rgba(239, 68, 68, .3);
  border-radius: 6px; padding: 8px 10px;
  color: #ef4444; font-size: 12px;
}
.login-submit {
  background: var(--accent, #22c55e); color: #ffffff;
  border: none; border-radius: 8px; padding: 11px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s; margin-top: 4px;
}
.login-submit:hover { background: #1aaf4e; }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 20px 0;
  color: var(--muted, #8896b3); font-size: 11px;
  text-transform: uppercase;
}
.login-divider::before, .login-divider::after {
  content: ""; flex: 1; height: 1px;
  background: rgba(127,127,127,.2);
}
.login-google { margin-bottom: 16px; }
.login-google-btn {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 10px; background: transparent;
  border: 1px solid rgba(127,127,127,.25);
  border-radius: 8px; padding: 10px 14px;
  color: var(--text, inherit); font-size: 14px;
  cursor: pointer; transition: background .15s; font-family: inherit;
}
.login-google-btn:hover { background: rgba(127,127,127,.06); }
.login-footer {
  text-align: center; color: var(--muted, #8896b3); font-size: 11px;
}

/* === Employee form: extras === */
.employee-pw-row { display: flex; gap: 6px; align-items: stretch; margin-top: 4px; }
.employee-pw-row input { flex: 1; }
.employee-pw-row button {
  white-space: nowrap;
  background: rgba(127,127,127,.08);
  border: 1px solid rgba(127,127,127,.15);
  border-radius: 6px; padding: 0 10px;
  font-size: 12px; cursor: pointer;
  color: var(--text, inherit);
}
.employee-pw-row button:hover { background: rgba(127,127,127,.15); }
.employee-pw-hint {
  display: block; font-size: 11px;
  color: var(--muted, #8896b3); margin-top: 4px;
}
