/* ENTENA CRM 2.0 — тёмная тема в стиле entena.by */
:root {
  --bg: #0b0d12;
  --bg2: #10131b;
  --card: #151925;
  --card2: #1a1f2e;
  --line: #232a3d;
  --text: #e8ecf6;
  --muted: #8b94ad;
  --blue: #4a8cff;
  --blue-soft: rgba(74, 140, 255, .12);
  --orange: #ff7a2f;
  --orange-soft: rgba(255, 122, 47, .12);
  --green: #3ed6a5;
  --red: #ff5d6c;
  --purple: #c07cff;
  --yellow: #ffd166;
  --radius: 14px;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
.ic {
  display: inline-flex; flex-shrink: 0; vertical-align: -2px;
  stroke: currentColor; fill: none; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}
.nav-item .ic { stroke-width: 1.8; }
.btn .ic { margin-right: 2px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; }
body {
  font-family: 'Montserrat', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Вход ---------- */
.login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 20px;
  background: radial-gradient(1200px 800px at 70% -10%, rgba(74,140,255,.16), transparent 60%),
              radial-gradient(900px 700px at 10% 110%, rgba(255,122,47,.12), transparent 55%),
              var(--bg);
}
.login-bg-glow { position: absolute; border-radius: 50%; filter: blur(120px); opacity: .5; pointer-events: none; }
.login-bg-glow.g1 { width: 420px; height: 420px; background: rgba(74,140,255,.35); top: -120px; right: -80px; }
.login-bg-glow.g2 { width: 380px; height: 380px; background: rgba(255,122,47,.25); bottom: -140px; left: -60px; }
.login-card {
  width: 420px; max-width: 100%; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 36px; position: relative; z-index: 1; box-shadow: var(--shadow);
}
.login-logo { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; margin-bottom: 28px; }
.logo-mark {
  width: 46px; height: 46px; border-radius: 13px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; color: #fff;
  background: linear-gradient(135deg, var(--blue), #6f5cff 60%, var(--orange));
  box-shadow: 0 6px 20px rgba(74,140,255,.35);
}
.logo-img { display: block; width: 150px; height: auto; }
.logo-word { font-size: 22px; font-weight: 800; letter-spacing: .06em; }
.logo-word span { color: var(--blue); }
.logo-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.login-card label { display: block; margin-bottom: 16px; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.login-card input {
  width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 14px; outline: none; transition: border .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.login-error { background: rgba(255,93,108,.12); color: var(--red); border: 1px solid rgba(255,93,108,.3); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; font-size: 13px; }
.login-demo { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.9; }
.login-demo code { background: var(--bg2); padding: 2px 6px; border-radius: 6px; color: var(--yellow); }
.demo-role { color: var(--blue); cursor: pointer; text-decoration: underline dotted; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-logo { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 22px 16px 18px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.sidebar-logo .logo-img { width: 120px; }
.sidebar-logo .logo-word { font-size: 15px; white-space: nowrap; }
.nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); cursor: pointer; font-weight: 600; margin-bottom: 2px; border: 1px solid transparent;
  transition: background .15s, color .15s; user-select: none; font-size: 13.5px;
}
.nav-item:hover { background: var(--card); color: var(--text); }
.nav-item.active { background: var(--blue-soft); color: var(--blue); border-color: rgba(74,140,255,.25); }
.nav-item .ni { width: 20px; text-align: center; font-size: 15px; }
.nav-badge { margin-left: auto; background: var(--orange); color: #fff; font-size: 10.5px; padding: 2px 7px; border-radius: 10px; font-weight: 700; }
.sidebar-footer { padding: 14px; border-top: 1px solid var(--line); }
.user-card { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.user-meta { flex: 1; min-width: 0; }
.user-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #fff; flex-shrink: 0; background: var(--blue);
}
.icon-btn { background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); color: var(--text); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px 32px 0;
}
.topbar h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.content { padding: 22px 32px 40px; flex: 1; }

/* ---------- Кнопки, поля ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid transparent;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: filter .15s, background .15s; background: var(--card2); color: var(--text);
}
.btn:hover { filter: brightness(1.12); }
.btn-primary { background: linear-gradient(135deg, var(--blue), #6f5cff); color: #fff; box-shadow: 0 6px 18px rgba(74,140,255,.3); }
.btn-orange { background: linear-gradient(135deg, var(--orange), #ff9d4d); color: #fff; box-shadow: 0 6px 18px rgba(255,122,47,.3); }
.btn-danger { background: rgba(255,93,108,.12); color: var(--red); border-color: rgba(255,93,108,.3); }
.btn-block { width: 100%; justify-content: center; }
.btn.sm { padding: 6px 10px; font-size: 12px; }

.grid { display: grid; gap: 16px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: 2fr 1fr; }
.grid.cards-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card h3 { font-size: 14px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--stat-color, var(--blue)); border-radius: 3px 3px 0 0;
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 26px; font-weight: 800; margin-top: 8px; }
.stat-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat-value, .money { font-variant-numeric: tabular-nums; }

/* ---------- Таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
td { padding: 12px; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(74,140,255,.04); }
.cell-title { font-weight: 700; }
.cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.row-actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }

/* ---------- Бейджи ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; border: 1px solid; white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.blue   { color: var(--blue);   background: var(--blue-soft);   border-color: rgba(74,140,255,.3); }
.badge.orange { color: var(--orange); background: var(--orange-soft); border-color: rgba(255,122,47,.3); }
.badge.green  { color: var(--green);  background: rgba(62,214,165,.1);  border-color: rgba(62,214,165,.3); }
.badge.red    { color: var(--red);    background: rgba(255,93,108,.1);  border-color: rgba(255,93,108,.3); }
.badge.gray   { color: var(--muted);  background: rgba(139,148,173,.1);  border-color: rgba(139,148,173,.25); }
.badge.purple { color: var(--purple); background: rgba(192,124,255,.1);  border-color: rgba(192,124,255,.3); }
.badge.yellow { color: var(--yellow); background: rgba(255,209,102,.1);  border-color: rgba(255,209,102,.3); }
.badge.bare::before { display: none; }

/* ---------- Прогресс, канбан ---------- */
.progress { height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; width: 120px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--green)); border-radius: 6px; }
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; align-items: start; }
.kanban-col { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban-col h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; }
.kanban-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 8px; cursor: pointer;
  transition: border .15s, transform .15s;
}
.kanban-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.kanban-card .t-title { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.kanban-card .t-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }
.kanban-card .t-meta { flex-wrap: wrap; gap: 6px 10px; margin-top: 6px; }
.kanban-card .t-title { line-height: 1.35; }

/* ---------- Лента активности ---------- */
.feed-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.feed-text { font-size: 13px; line-height: 1.5; }
.feed-text b { color: var(--blue); }
.feed-time { color: var(--muted); font-size: 11.5px; }

/* ---------- Модалка ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5,7,12,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal {
  width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 26px; box-shadow: var(--shadow);
}
.modal h2 { font-size: 17px; margin-bottom: 20px; display: flex; justify-content: space-between; align-items: center; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg2); color: var(--text); font-size: 13.5px; outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.field textarea { resize: vertical; min-height: 80px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--blue); }

/* ---------- Комментарии ---------- */
.comments { margin-top: 6px; }
.comment { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.comment:last-child { border-bottom: none; }
.comment-body { font-size: 13px; line-height: 1.5; }
.comment .feed-time { margin-top: 2px; }

/* ---------- Тосты ---------- */
.toast-wrap { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--card2); border: 1px solid var(--green); color: var(--text); border-radius: 10px;
  padding: 12px 18px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
.toast.err { border-color: var(--red); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

.empty { text-align: center; color: var(--muted); padding: 40px 0; font-size: 13px; }
.muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; }

/* ---------- Права (матрица) ---------- */
.perm-grid { display: grid; grid-template-columns: 140px repeat(3, 80px); gap: 8px; align-items: center; }
.perm-grid .perm-head { font-size: 11px; color: var(--muted); text-transform: uppercase; text-align: center; font-weight: 700; }
.perm-grid .perm-cell { text-align: center; }
.perm-pill { display: inline-block; padding: 3px 12px; border-radius: 14px; font-size: 11.5px; font-weight: 700; }
.perm-pill.yes { background: var(--blue-soft); color: var(--blue); }
.perm-pill.no { background: rgba(139,148,173,.08); color: var(--muted); }

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .grid.cards-2 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .mobile-logo { display: block !important; width: 100px; margin: 0 auto 14px; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .grid.cols-4 { grid-template-columns: 1fr; }
  .grid.cards-2 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}