.crm-shell { display:flex; flex-direction:column; height:100vh; background:var(--bg); color:var(--text); }
.crm-head { display:flex; align-items:center; gap:16px; padding:14px 20px; border-bottom:1px solid var(--border); background:var(--panel); }
.crm-head h1 { margin:0; font-size:18px; }
.crm-tabs { display:flex; gap:4px; }
.crm-tab { background:none; border:none; color:var(--muted); padding:8px 14px; border-radius:var(--radius); cursor:pointer; font-size:14px; }
.crm-tab.active { color:var(--accent); background:var(--panel2); font-weight:600; }
.crm-view { flex:1; overflow:auto; padding:20px; }
.crm-view.hidden { display:none; }
.crm-stats { display:flex; gap:10px; flex-wrap:wrap; margin-bottom:16px; }
.crm-stat { background:var(--panel); border:1px solid var(--border); border-radius:var(--radius); padding:12px 16px; min-width:120px; }
.crm-stat .v { font-size:18px; font-weight:700; }
.crm-stat .l { font-size:11px; color:var(--muted); }
.crm-badge { display:inline-block; padding:2px 8px; border-radius:999px; font-size:12px; font-weight:600; }
.stage-Lead { background:#3b4252; }
.stage-Contact { background:#4c566a; }
.stage-Proposal { background:#5e81ac; }
.stage-Negotiation { background:#b48ead; }
.stage-Won { background:#a3be8c; color:#1a1e24; }
.stage-Lost { background:#bf616a; }
.priority-Low { color:var(--muted); }
.priority-Normal { color:#ebcb8b; }
.priority-High { color:#bf616a; }
.toolbar { display:flex; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:16px; }
.toolbar label { display:flex; align-items:center; gap:6px; color:var(--muted); font-size:13px; cursor:pointer; }
.toolbar input[type="text"], .toolbar input:not([type]), .toolbar select { width:auto; min-width:150px; }
.table td, .table th { white-space:nowrap; }
.table td:nth-child(2) { white-space:normal; min-width:160px; }
.table a { color:var(--accent); text-decoration:none; }
.table a:hover { text-decoration:underline; }
.crm-empty { padding:30px; text-align:center; color:var(--muted); }
.view-toggle { display:flex; gap:4px; margin-left:auto; }
.view-toggle .btn.active { background:var(--accent); color:#000; border-color:var(--accent); }

/* ---------- Канбан ---------- */
.kanban { display:flex; gap:12px; overflow-x:auto; padding-bottom:12px; align-items:flex-start; }
.kanban-col {
  min-width:230px; width:230px; flex-shrink:0; background:var(--panel);
  border:1px solid var(--border); border-radius:var(--radius); display:flex; flex-direction:column;
  max-height:calc(100vh - 240px);
}
.kanban-col.dragover { border-color:var(--accent); box-shadow:0 0 0 1px var(--accent); }
.kanban-head {
  padding:10px 12px; font-weight:600; font-size:13px; display:flex; justify-content:space-between;
  border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--panel);
}
.kanban-head .cnt { color:var(--muted); font-weight:400; }
.kanban-cards { padding:8px; display:flex; flex-direction:column; gap:8px; overflow-y:auto; }
.kanban-card {
  background:var(--panel2); border:1px solid var(--border); border-radius:8px;
  padding:10px; cursor:grab; font-size:13px; transition:border-color .12s;
}
.kanban-card:hover { border-color:var(--accent); }
.kanban-card:active { cursor:grabbing; }
.kanban-card .t { font-weight:600; margin-bottom:4px; }
.kanban-card .m { color:var(--muted); font-size:12px; display:flex; justify-content:space-between; gap:6px; }
.kanban-card .amt { color:var(--accent); font-weight:600; }
.kanban-empty { color:var(--muted); font-size:12px; text-align:center; padding:14px 8px; }

/* ---------- Аналитика ---------- */
.analytics-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(340px,1fr)); gap:16px; }
.analytics-grid .card { padding:16px; }

/* ---------- Позиции сделки ---------- */
.deal-items { margin-top:12px; border-top:1px solid var(--border); padding-top:10px; }
.deal-items table { width:100%; font-size:13px; }
.deal-items td { padding:4px 6px; }
.deal-item-add { display:flex; gap:8px; margin-top:8px; flex-wrap:wrap; }
.deal-item-add input, .deal-item-add select { width:auto; flex:1; min-width:90px; padding:6px 8px; font-size:13px; }

/* ---------- Мобильная версия CRM ---------- */
@media (max-width: 720px) {
  .crm-head { flex-wrap:wrap; padding:10px 12px; gap:8px; }
  .crm-head h1 { font-size:16px; }
  .crm-view { padding:12px; }
  .crm-stats { gap:8px; }
  .crm-stat { min-width:calc(50% - 8px); padding:10px 12px; }
  .table { display:block; overflow-x:auto; }
  .kanban-col { min-width:200px; width:200px; }
  .toolbar input:not([type]), .toolbar select { min-width:120px; flex:1; }
  .view-toggle { margin-left:0; }
}

/* Лента активности сделки */
.feed-list { max-height: 220px; overflow-y: auto; border: 1px solid var(--border, #333); border-radius: 8px; padding: 6px 10px; }
.feed-row { display: flex; gap: 10px; padding: 4px 0; border-bottom: 1px solid var(--border, #333); font-size: 13px; align-items: baseline; }
.feed-row:last-child { border-bottom: none; }
.feed-when { color: var(--dim); font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.feed-row.sys span:last-child { color: var(--dim); }

/* План продаж: прогресс-бар */
.plan-bar { height: 8px; border-radius: 4px; background: var(--border, #333); margin-top: 8px; overflow: hidden; }
.plan-bar > div { height: 100%; border-radius: 4px; background: var(--accent, #4f8cff); transition: width .3s; }
