/* ══════════════════════════════════════════════════════════
   Priority CRM v6 — корпоративный стиль ГК Приоритет
   Палитра: зелёный логотипа (#2e7d32 → #4caf50) +
   тёмный фон / светлый фон в тон старого dashboard.
   ══════════════════════════════════════════════════════════ */

:root {
  /* ── Бренд ── */
  --brand-1: #2e7d32;        /* тёмно-зелёный логотипа */
  --brand-2: #4caf50;        /* светло-зелёный логотипа */
  --brand-3: #1f5e23;        /* ещё темнее, для hover */
  --brand-4: #66bb6a;        /* светлее для светлой темы */
  --brand-gradient: linear-gradient(135deg, #2e7d32, #4caf50);

  /* ── Тёмная тема (по умолчанию) ── */
  --bg:        #0d1117;      /* общий фон (github-dark) */
  --bg-card:   #161b22;      /* карточки */
  --bg-elev:   #1c2128;      /* инпуты, elevated */
  --bg-hover:  #222822;      /* hover-зелёный */
  --border:    #21262d;
  --border-2:  #2a322a;      /* чуть зеленее */
  --text:      #e6edf3;
  --text-dim:  #9aa5b1;
  --text-mute: #636c76;

  --primary:   #4caf50;
  --primary-h: #66bb6a;
  --primary-d: #2e7d32;
  --accent:    #26a69a;      /* бирюзовый */
  --info:      #58a6ff;
  --warn:      #e3b341;
  --danger:    #f85149;
  --success:   #3fb950;

  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);

  --sb-w: 260px;
  --top-h: 60px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:        #f5f7f5;       /* зеленоватый тёплый белый */
    --bg-card:   #ffffff;
    --bg-elev:   #ffffff;
    --bg-hover:  #e8f5e9;       /* очень светло-зелёный */
    --border:    #d4e1d4;
    --border-2:  #c8deca;
    --text:      #1b2920;
    --text-dim:  #4a5c4f;
    --text-mute: #7a8a7d;
    --shadow:    0 10px 30px rgba(46, 125, 50, 0.08);
    --shadow-sm: 0 2px 8px rgba(46, 125, 50, 0.06);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

html, body { max-width: 100vw; overflow-x: hidden; }
body { display: flex; min-height: 100vh; }

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

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.15);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sb-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  z-index: 100;
}

.sb-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(46, 125, 50, 0.08), transparent);
}
.sb-logo {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: white;
  display: grid; place-items: center;
  padding: 4px;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.35);
  overflow: hidden;
}
.sb-logo img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
.sb-name {
  font-weight: 700; font-size: 16px;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.sb-sub { font-size: 11px; color: var(--text-mute); letter-spacing: 0.5px; text-transform: uppercase; }

.sb-menu {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  position: relative;
}
.sb-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.sb-item.active {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.18), rgba(38, 166, 154, 0.1));
  color: var(--primary);
  font-weight: 600;
}
.sb-item .ico { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.sb-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Плашки NEW/UPD в меню ── */
.menu-badge {
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.4px;
  line-height: 1.3;
  flex-shrink: 0;
  text-transform: uppercase;
}
.mb-new { background: var(--brand-2); color: #0b1a0c; }
.mb-upd { background: var(--info); color: #0b1a0c; }
.mb-fix { background: var(--warn); color: #3a2a00; }
.mb-sec { background: var(--danger); color: white; }
.mb-dsn { background: var(--accent); color: #00231f; }

.sb-user {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--border);
}
.sb-user-ava {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand-gradient);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  color: white;
  flex-shrink: 0;
}
.sb-user-info { flex: 1; min-width: 0; }
.sb-user-name {
  font-size: 13px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sb-user-role { font-size: 11px; color: var(--text-mute); }
.sb-logout {
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--text-mute);
  font-size: 18px;
  transition: background 0.15s, color 0.15s;
}
.sb-logout:hover { background: var(--bg-hover); color: var(--danger); }

/* ══════════════════════════════════════════════════════════
   MAIN / TOPBAR
   ══════════════════════════════════════════════════════════ */

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

.topbar {
  height: var(--top-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-title {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.branch-badge {
  padding: 6px 12px;
  background: var(--bg-hover);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 18px;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--primary); }

#btn-menu-toggle { display: none; }

.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── legacy iframe ── */
.legacy-frame {
  width: 100%;
  height: 100%;
  min-height: calc(100vh - var(--top-h));
  border: none;
  background: var(--bg);
  display: block;
}

/* ══════════════════════════════════════════════════════════
   CARDS / KPI / GRID
   ══════════════════════════════════════════════════════════ */

.grid { display: grid; gap: 16px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.card {
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-hdr {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.card-title { font-size: 14px; font-weight: 600; flex: 1; min-width: 0; }
.card-sub { font-size: 12px; color: var(--text-mute); }

.kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, border-color 0.15s;
}
.kpi:hover { transform: translateY(-2px); border-color: var(--brand-2); }
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0;
  width: 3px; height: 100%;
  background: var(--brand-gradient);
  opacity: 0.7;
}
.kpi-label {
  font-size: 12px;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.kpi-value {
  font-size: 30px;
  font-weight: 700;
  margin-top: 6px;
  line-height: 1.1;
  color: var(--text);
}
.kpi-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.kpi-ico {
  position: absolute;
  top: 14px; right: 16px;
  font-size: 28px;
  opacity: 0.4;
}

/* ══════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════ */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-elev);
  position: sticky; top: 0;
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* ══════════════════════════════════════════════════════════
   BUTTONS / BADGES
   ══════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: transform 0.1s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: var(--brand-gradient);
  color: white;
  box-shadow: 0 4px 14px rgba(76, 175, 80, 0.35);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(76, 175, 80, 0.5); }
.btn-ghost {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { border-color: var(--brand-2); color: var(--primary); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #d73a3a; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-dim);
}
.badge-success { background: rgba(63, 185, 80, 0.15); color: var(--success); }
.badge-warn { background: rgba(227, 179, 65, 0.18); color: var(--warn); }
.badge-danger { background: rgba(248, 81, 73, 0.15); color: var(--danger); }
.badge-info { background: rgba(88, 166, 255, 0.15); color: var(--info); }

.badge-type-new { background: rgba(76, 175, 80, 0.18); color: var(--brand-2); }
.badge-type-upd { background: rgba(88, 166, 255, 0.18); color: var(--info); }
.badge-type-fix { background: rgba(227, 179, 65, 0.18); color: var(--warn); }
.badge-type-sec { background: rgba(248, 81, 73, 0.18); color: var(--danger); }
.badge-type-dsn { background: rgba(38, 166, 154, 0.18); color: var(--accent); }

/* ══════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════ */

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
  margin-top: 14px;
}
label:first-child { margin-top: 0; }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin: 0;
  color: var(--text);
}
.chip:has(input:checked) {
  background: rgba(76, 175, 80, 0.18);
  border-color: var(--primary);
  color: var(--primary);
}
.chip input { width: auto; margin: 0; }

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  z-index: 1000;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-box h2 { margin-bottom: 8px; font-size: 18px; }
.modal-box p.muted { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

/* ══════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 20px; left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  box-shadow: var(--shadow);
  transition: transform 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2), opacity 0.2s, visibility 0.2s;
  z-index: 2000;
  max-width: 90vw;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; pointer-events: auto; }
.toast:empty { display: none !important; }
.toast.err { border-left-color: var(--danger); color: var(--danger); }
.toast.ok { border-left-color: var(--success); color: var(--success); }

/* ══════════════════════════════════════════════════════════
   LOADER / EMPTY
   ══════════════════════════════════════════════════════════ */

.loader { display: grid; place-items: center; min-height: 240px; }
.spinner {
  width: 42px; height: 42px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}
.overlay.show { display: block; }

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-mute);
}
.empty .emoji { font-size: 48px; margin-bottom: 12px; }
.empty h3 { font-size: 16px; margin-bottom: 6px; color: var(--text-dim); }

.muted { color: var(--text-mute); }
.hidden { display: none !important; }
.row { display: flex; align-items: center; gap: 12px; }
.space { flex: 1; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }

/* ══════════════════════════════════════════════════════════
   UPDATES (changelog)
   ══════════════════════════════════════════════════════════ */

.upd-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.upd-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-2);
  border-radius: var(--radius);
  padding: 16px 20px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.upd-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.upd-title { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.upd-body {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.6;
  white-space: pre-wrap;
}
.upd-meta {
  display: flex;
  gap: 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-mute);
  flex-wrap: wrap;
}
.upd-del {
  position: absolute;
  top: 10px; right: 10px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg-hover);
  color: var(--text-mute);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  transition: all 0.15s;
}
.upd-del:hover { background: var(--danger); color: white; }

/* ══════════════════════════════════════════════════════════
   FEEDBACK
   ══════════════════════════════════════════════════════════ */

.fb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.fb-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.fb-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  margin-left: 4px;
}
.fb-meta { font-size: 12px; color: var(--text-mute); margin-bottom: 10px; }
.fb-body {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.55;
  white-space: pre-wrap;
}
.fb-mod {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.fb-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.fb-shots {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.fb-shots img {
  max-width: 180px;
  max-height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  object-fit: cover;
  transition: transform 0.15s;
}
.fb-shots a:hover img { transform: scale(1.03); border-color: var(--primary); }

.fb-shots-prev {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  min-height: 10px;
}
.shot-prev {
  position: relative;
  width: 110px;
  height: 80px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-elev);
}
.shot-prev img { width: 100%; height: 100%; object-fit: cover; }
.shot-del {
  position: absolute;
  top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: 14px;
  line-height: 1;
  font-weight: 700;
}
.shot-del:hover { background: var(--danger); }

/* ══════════════════════════════════════════════════════════
   MOBILE
   ══════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 280px;
    max-width: 85vw;
  }
  .sidebar.open { transform: translateX(0); }
  #btn-menu-toggle { display: grid; }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
  .branch-badge { display: none; }
  .kpi-value { font-size: 24px; }
  th, td { padding: 10px 12px; font-size: 13px; }
  .fb-shots img { max-width: 45vw; }
  .modal-box { padding: 20px; }
}

@media (max-width: 500px) {
  .content { padding: 10px; }
  .card { padding: 14px; }
}


/* ══════════════════════════════════════════════════════════
   DASHBOARD — воронка, алерты, лиды
   ══════════════════════════════════════════════════════════ */

.kpi.kpi-success::before { background: linear-gradient(180deg, var(--success), #2ea043); }
.kpi.kpi-warn::before { background: linear-gradient(180deg, var(--warn), #d08900); }
.kpi.kpi-danger::before { background: linear-gradient(180deg, var(--danger), #b62324); }

.funnel {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.funnel-row {
  display: grid;
  grid-template-columns: minmax(120px, 150px) 1fr 50px 42px;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--bg-elev);
  transition: background 0.15s, transform 0.15s;
  cursor: pointer;
}
.funnel-row:hover {
  background: var(--bg-hover);
  transform: translateX(2px);
}
.funnel-label {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.funnel-bar {
  height: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
@media (prefers-color-scheme: light) {
  .funnel-bar { background: rgba(0,0,0,0.06); }
}
.funnel-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.2, 0.9, 0.3, 1);
  position: relative;
}
.funnel-count {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  text-align: right;
  tabular-nums: 1;
  font-variant-numeric: tabular-nums;
}
.funnel-pct {
  font-size: 11px;
  color: var(--text-mute);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}
.alert-item.alert-urgent { border-left-color: var(--danger); }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--warn);
  margin-top: 6px;
  flex-shrink: 0;
}
.alert-urgent .alert-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(248,81,73,0.18); }
.alert-text { flex: 1; min-width: 0; }
.alert-text b { color: var(--primary); }

.lead-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lead-item {
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  position: relative;
}
.lead-item:hover { border-color: var(--brand-2); }
.lead-name { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.lead-meta { font-size: 12px; color: var(--text-dim); }
.lead-details { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.lead-time {
  position: absolute; top: 10px; right: 12px;
  font-size: 11px;
  color: var(--text-mute);
}


/* ══════════════════════════════════════════════════════════
   Компоненты v6.2: kanban, deal-card, routes, toolbar,
   modal-head, requests, stops, orders, settings tiles
   ══════════════════════════════════════════════════════════ */

/* ── Общий toolbar и page-head ── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.page-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.page-h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.view-switch {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.view-switch .btn {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--text-dim);
  padding: 6px 14px;
}
.view-switch .btn.active {
  background: var(--brand-gradient);
  color: white;
}

/* ── Modal с заголовком и крестиком ── */
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.modal-close {
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 22px;
  color: var(--text-mute);
  background: transparent;
  line-height: 1;
}
.modal-close:hover { background: var(--bg-hover); color: var(--danger); }

/* ── KANBAN (сделки, маршруты) ── */
.kanban, .routes-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.kanban-col, .routes-col {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 260px);
}
.kanban-col-hdr, .routes-col-hdr {
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-elev);
  border-top: 3px solid var(--brand-2);
  border-bottom: 1px solid var(--border);
}
.kanban-count {
  background: var(--bg-hover);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.kanban-list {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.deal-card, .route-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}
.deal-card:hover, .route-card:hover {
  border-color: var(--brand-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.15);
}
.deal-name, .route-id {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}
.deal-amount {
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.deal-meta, .route-driver, .route-vehicle, .route-date {
  font-size: 12px;
  color: var(--text-dim);
}
.deal-time {
  font-size: 11px;
  color: var(--text-mute);
  margin-top: 4px;
}

.route-progress {
  margin-top: 10px;
}
.route-progress-bar {
  height: 6px;
  background: var(--bg-hover);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.route-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-1), var(--brand-2));
  border-radius: 3px;
  transition: width 0.4s;
}
.route-progress-text {
  font-size: 11px;
  color: var(--text-mute);
  text-align: right;
}

/* ── Stops list ── */
.stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.stop-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  align-items: flex-start;
}
.stop-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.stop-info { flex: 1; min-width: 0; font-size: 13px; }
.stop-client { font-weight: 600; margin-bottom: 2px; }
.stop-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* ── Orders picker (в модале создания маршрута) ── */
.orders-picker {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px;
}
.order-pick {
  display: flex;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
  font-size: 13px;
}
.order-pick:hover { border-color: var(--primary); }
.order-pick.selected {
  background: rgba(76, 175, 80, 0.1);
  border-color: var(--primary);
}
.order-chk {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}
.order-pick.selected .order-chk {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.order-title { font-weight: 600; }

/* ── Request-item (в клиентах) ── */
.request-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--warn);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.request-info { flex: 1; min-width: 0; }

/* ── Notes list (в сделках) ── */
.notes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}
.note-item {
  padding: 8px 10px;
  background: var(--bg-elev);
  border-left: 2px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ── Settings tiles ── */
.settings-tile {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  display: block;
  text-decoration: none;
  color: inherit;
}
.settings-tile:hover {
  border-color: var(--brand-2);
  transform: translateY(-2px);
  text-decoration: none;
}
.settings-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

/* ── Crop card (в базе знаний) ── */
.crop-card {
  transition: transform 0.15s, border-color 0.15s;
  cursor: pointer;
}
.crop-card:hover {
  border-color: var(--brand-2);
  transform: translateY(-2px);
}

/* ── Branch tile ── */
.branch-tile {
  transition: transform 0.12s;
}
.branch-tile:hover { transform: translateY(-2px); }

/* ── Mobile kanban ── */
@media (max-width: 900px) {
  .kanban, .routes-board {
    grid-template-columns: 1fr;
  }
  .kanban-col, .routes-col { max-height: none; }
  .toolbar { gap: 8px; }
  .view-switch .btn { padding: 5px 10px; font-size: 12px; }
}


/* ══════════════════════════════════════════════════════════
   Stock table — раскрываемые партии
   ══════════════════════════════════════════════════════════ */

.stock-table .stock-row {
  transition: background 0.1s;
}
.stock-table .stock-row:hover {
  background: var(--bg-hover);
}
.row-expand {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--text-mute);
  font-size: 12px;
  line-height: 1;
  transition: transform 0.15s, color 0.15s;
  padding: 0;
  display: grid;
  place-items: center;
}
.row-expand.open {
  color: var(--primary);
  transform: rotate(0);
}
.row-expand:hover { background: var(--bg-elev); color: var(--primary); }

.batch-row.hidden { display: none; }
.batch-row td {
  padding: 0 !important;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
}
.batch-container {
  padding: 14px 20px 14px 52px;
  background: var(--bg);
}
.batch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.batch-table th, .batch-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.batch-table th {
  font-size: 10px;
  color: var(--text-mute);
  background: var(--bg-elev);
  font-weight: 600;
}
.batch-table tbody tr:last-child td { border-bottom: none; }
.batch-table tbody tr:hover { background: var(--bg-hover); }


/* База знаний — карточки болезней */
.kb-disease-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
  margin-top: 12px;
}
.kb-disease {
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-2);
  border-radius: var(--radius-sm);
}
.kb-disease-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}


/* Препараты МСХ в базе знаний */
.kb-prep-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.kb-prep {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
  min-width: 0;
  overflow: hidden;
}
.kb-prep > * { min-width: 0; max-width: 100%; overflow: hidden; }
.kb-prep-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kb-prep:hover {
  border-color: var(--brand-2);
  transform: translateY(-1px);
}
.kb-prep-name { font-size: 14px; font-weight: 600; }
.kb-prep-meta {
  font-size: 12px;
  margin-top: 4px;
  color: var(--text-dim);
}

.section-h {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* Продуктовая карточка */
.product-card {
  cursor: pointer;
  transition: border-color 0.15s, transform 0.12s;
}
.product-card:hover {
  border-color: var(--brand-2);
  transform: translateY(-2px);
}

/* Чипы культур */
.mcx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.mcx-chip {
  background: rgba(76, 175, 80, 0.15);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
}
