:root {
  --brand: #3B82F6;
  --brand-600: #2563EB;
  --brand-700: #1D4ED8;
  --brand-50: #EFF6FF;
  --brand-100: #DBEAFE;
  --ink: #0F172A;
  --ink-2: #334155;
  --muted: #64748B;
  --line: #E2E8F0;
  --bg: #F5F7FB;
  --card: #FFFFFF;
  --green: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --sidebar: 252px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 20px; }
h3 { font-size: 15px; font-weight: 700; }
a { color: var(--brand-600); text-decoration: none; }
.muted { color: var(--muted); }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }

/* ---------- Кнопки и поля ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(59, 130, 246, .3); }
.btn-primary:hover { background: var(--brand-600); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-light { background: #fff; color: var(--brand-700); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

input, select {
  width: 100%; height: 42px; padding: 0 12px; margin-top: 6px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  font: inherit; color: var(--ink); outline: none;
}
input:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-100); }
label { display: block; font-weight: 500; color: var(--ink-2); font-size: 13px; }

.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  display: inline-grid; place-items: center; cursor: pointer; flex: none;
}
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

/* ---------- Бренд ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand) 0%, #6366F1 100%); color: #fff; font-weight: 800; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-weight: 800; letter-spacing: .04em; font-size: 15px; }
.brand-text small { font-size: 10px; letter-spacing: .3em; color: var(--muted); font-weight: 600; }
.brand-lg .brand-mark { width: 44px; height: 44px; font-size: 22px; }

/* ---------- Переключатель языка ---------- */
.lang-switch { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex: none; }
.lang-switch button { border: 0; background: none; font: inherit; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--muted); padding: 6px 10px; border-radius: 7px; cursor: pointer; }
.lang-switch button:hover { color: var(--ink); }
.lang-switch button.on { background: var(--brand); color: #fff; }
.login-lang { position: absolute; top: 24px; right: 24px; }

/* ---------- Вход ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, 480px) 1fr; }
.login-card { position: relative; padding: 56px 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px; background: #fff; }
.login-card h1 { margin-top: 24px; }
.login-card form { display: grid; gap: 14px; margin-top: 8px; }
.login-foot { font-size: 12px; font-style: italic; margin-top: 12px; }
.login-art {
  position: relative; overflow: hidden;
  background:
    radial-gradient(600px 400px at 70% 20%, rgba(255, 255, 255, .18), transparent 60%),
    linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 55%, #312E81 100%);
}
.art-card {
  position: absolute; background: rgba(255, 255, 255, .14); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .25); color: #fff; border-radius: 18px; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 4px; min-width: 220px; box-shadow: 0 20px 50px rgba(15, 23, 42, .25);
}
.art-card span { opacity: .8; font-size: 13px; }
.art-card b { font-size: 26px; font-weight: 800; }
.art-card i, .art-card i.up { font-style: normal; font-weight: 600; font-size: 13px; color: #A7F3D0 !important; }
.a1 { top: 22%; left: 14%; }
.a2 { top: 46%; left: 48%; }
.a3 { top: 68%; left: 20%; }

/* ---------- Каркас ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar); flex: none; background: #fff; border-right: 1px solid var(--line);
  padding: 22px 16px; display: flex; flex-direction: column; gap: 28px;
  position: sticky; top: 0; height: 100vh; z-index: 30;
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.nav a.active svg { color: var(--brand); }
.nav svg { color: #94A3B8; }
.badge { margin-left: auto; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; }
.badge:empty { display: none; }
.sidebar-promo {
  margin-top: auto; padding: 18px; border-radius: 14px; color: #fff;
  background: linear-gradient(140deg, var(--brand) 0%, var(--brand-700) 100%);
}
.sidebar-promo .btn { white-space: normal; height: auto; min-height: 32px; padding: 6px 12px; text-align: center; }
.sidebar-promo p { margin: 6px 0 12px; font-size: 12px; opacity: .9; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: rgba(245, 247, 251, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.menu-btn { display: none; }
.search { position: relative; flex: 1; max-width: 460px; margin-right: auto; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 18px; height: 18px; }
.search input { margin: 0; padding-left: 38px; background: #fff; }
.user { display: flex; align-items: center; gap: 10px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); font-size: 12px; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--brand-100); color: var(--brand-700); font-weight: 700; font-size: 13px; flex: none;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; border: 2px solid #fff; }
.av-AK { background: #FEF3C7; color: #B45309; }
.av-MS { background: #D1FAE5; color: #047857; }

.view { padding: 28px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; font: inherit; font-weight: 500; color: var(--muted); padding: 6px 14px; border-radius: 8px; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid rgba(226, 232, 240, .6); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; gap: 8px; }
.card > h3 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- Обзор ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%; background: var(--brand-50); }
.kpi span { color: var(--muted); font-size: 13px; position: relative; z-index: 1; }
.kpi b { font-size: 24px; font-weight: 800; position: relative; z-index: 1; }
.kpi i { font-style: normal; font-size: 12px; font-weight: 600; color: var(--muted); }
.up { color: var(--green) !important; }
.down { color: var(--red) !important; }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 220px; padding-top: 18px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; }
.bar i { width: 100%; max-width: 48px; background: var(--brand-100); border-radius: 10px 10px 4px 4px; position: relative; transition: height .4s; }
.bar.current i { background: linear-gradient(180deg, var(--brand) 0%, var(--brand-700) 100%); }
.bar em { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; font-weight: 600; color: var(--ink-2); }
.bar span { font-size: 12px; color: var(--muted); }

.funnel-row { display: grid; grid-template-columns: 140px 1fr 28px; align-items: center; gap: 12px; padding: 9px 0; }
.funnel-row span { font-size: 13px; color: var(--ink-2); }
.funnel-bar { height: 12px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 99px; }
.funnel-row b { text-align: right; }

.mini-tasks, .feed, .tasks { list-style: none; margin: 0; padding: 0; }
.mini-tasks li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.mini-tasks li:last-child { border: 0; }
.mini-tasks small { color: var(--muted); white-space: nowrap; }
.tag { background: var(--brand-50); color: var(--brand-700); font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.feed li { display: flex; gap: 12px; padding: 9px 0; }
.feed p { margin: 0; }
.feed small { color: var(--muted); }

/* ---------- Сделки ---------- */
.board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #EEF2F8; border-radius: var(--radius); padding: 12px; min-height: 420px; transition: background .15s, outline-color .15s; outline: 2px dashed transparent; }
.col.over { background: var(--brand-50); outline-color: var(--brand); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 0; }
.col-head .count { margin-left: auto; background: #fff; border-radius: 99px; padding: 0 9px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pip { width: 10px; height: 10px; border-radius: 50%; }
.col-sum { font-size: 12px; color: var(--muted); padding: 2px 4px 12px; }
.col-body { display: flex; flex-direction: column; gap: 10px; }
.deal { background: #fff; border-radius: 12px; padding: 14px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06); cursor: grab; border: 1px solid transparent; display: flex; flex-direction: column; gap: 4px; }
.deal:hover { border-color: var(--brand-100); box-shadow: 0 6px 16px rgba(15, 23, 42, .08); }
.deal.dragging { opacity: .45; }
.deal h4 { font-size: 14px; margin-top: 6px; }
.deal p { margin: 0; font-size: 13px; }
.deal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.deal small { font-size: 11px; }
.svc { align-self: flex-start; font-size: 11px; font-weight: 600; color: var(--brand-700); background: var(--brand-50); padding: 2px 8px; border-radius: 6px; }

/* ---------- Клиенты ---------- */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 14px 20px; background: #FAFBFD; border-bottom: 1px solid var(--line); }
.table td { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.table tbody tr { cursor: pointer; transition: background .1s; }
.table tbody tr:hover { background: var(--brand-50); }
.table tr:last-child td { border-bottom: 0; }
.table td:first-child { display: flex; align-items: center; gap: 12px; }
.num { text-align: right !important; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px !important; display: table-cell !important; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--brand-100), #E0E7FF); color: var(--brand-700); font-weight: 800; flex: none; }
.logo.lg { width: 56px; height: 56px; font-size: 22px; border-radius: 14px; }
.status { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 99px; white-space: nowrap; }
.st-lead { background: #F1F5F9; color: #475569; }
.st-nego { background: #FEF3C7; color: #B45309; }
.st-client { background: #D1FAE5; color: #047857; }

/* ---------- Проекты ---------- */
.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.project { display: flex; flex-direction: column; gap: 6px; }
.project-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.project p { margin: 0 0 10px; }
.pstatus { font-size: 12px; font-weight: 600; color: var(--amber); }
.pstatus.done { color: var(--green); }
.progress { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand) 0%, #6366F1 100%); border-radius: 99px; }
.project-foot { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-weight: 600; }
.project-foot small { margin-left: auto; font-weight: 400; }
.team { display: flex; }
.team .avatar { margin-left: -8px; }
.team .avatar:first-child { margin-left: 0; }

/* ---------- Задачи ---------- */
.task-add { display: flex; gap: 10px; margin-bottom: 8px; }
.task-add input { margin: 0; }
.tasks li { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.tasks li:last-child { border: 0; }
.tasks label { display: flex; align-items: center; gap: 12px; flex: 1; cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 400; }
.tasks input[type=checkbox] { width: 20px; height: 20px; margin: 0; accent-color: var(--brand); flex: none; }
.tasks li.done label span { text-decoration: line-through; color: var(--muted); }
.tasks small { white-space: nowrap; }

/* ---------- Настройки ---------- */
.form { display: grid; gap: 14px; }
.form .btn { justify-self: start; }
.switches { display: flex; flex-direction: column; margin-bottom: 16px; }
.switch { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 400; }
.switch input { display: none; }
.switch i { width: 42px; height: 24px; border-radius: 99px; background: #CBD5E1; position: relative; transition: background .2s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(18px); }

/* ---------- Модалка, панель, тост ---------- */
.modal, .drawer { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; animation: fade .15s; }
.modal { align-items: center; justify-content: center; padding: 16px; }
.modal-box { background: #fff; border-radius: 18px; padding: 28px; width: 100%; max-width: 480px; box-shadow: 0 30px 80px rgba(15, 23, 42, .3); }
.modal-box form { display: grid; gap: 14px; margin-top: 18px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.drawer { justify-content: flex-end; }
.drawer-box { background: #fff; width: 100%; max-width: 440px; height: 100%; overflow-y: auto; padding: 28px; position: relative; display: flex; flex-direction: column; gap: 14px; animation: slide .2s; }
.drawer-box .close { position: absolute; top: 20px; right: 20px; }
.client-head { display: flex; gap: 16px; align-items: center; }
.client-head h2 { margin-bottom: 6px; }
.props { display: grid; grid-template-columns: 110px 1fr; gap: 10px; margin: 8px 0; padding: 16px; background: var(--bg); border-radius: 12px; }
.props dt { color: var(--muted); }
.props dd { margin: 0; font-weight: 500; word-break: break-word; }
.drawer-box .deal { cursor: default; border-color: var(--line); }
.drawer-actions { display: flex; gap: 10px; margin-top: auto; padding-top: 12px; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px; font-weight: 500; z-index: 60;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }

/* ---------- Адаптив ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .user-meta { display: none; }
}
@media (max-width: 960px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(15, 23, 42, .2); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; gap: 8px; }
  .view { padding: 20px 16px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi b { font-size: 18px; }
  #new-deal-btn { padding: 0 12px; }
  .user, .notif-btn { display: none; }
  .lang-switch button { padding: 6px 8px; }
  .hide-sm { display: none; }
  .table th, .table td { padding: 12px; }
  .login-card { padding: 40px 24px; }
  .row2 { grid-template-columns: 1fr; }
  .funnel-row { grid-template-columns: 100px 1fr 24px; }
}
