/* Примбас CRM — дизайн-система */
:root {
  --bg: #f4f7f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  /* фирменные цвета логотипа: бирюзовый #1b7685, тёмно-синий #003c5a */
  --brand: #1b7685;
  --brand-600: #145e6a;
  --brand-50: #eaf5f6;
  --brand-100: #cde7ea;
  --accent: #2a9bab;
  --navy: #003c5a;
  --sidebar: #002b41;
  --sidebar-2: #0a3d57;
  --sidebar-text: #b3cad6;
  --green: #16a34a; --green-bg: #dcfce7;
  --red: #dc2626;   --red-bg: #fee2e2;
  --amber: #b45309; --amber-bg: #fef3c7;
  --blue: #2563eb;  --blue-bg: #dbeafe;
  --violet: #7c3aed; --violet-bg: #ede9fe;
  --teal: #0f766e;  --teal-bg: #ccfbf1;
  --gray-bg: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-600); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
h1 { font-size: 22px; letter-spacing: -.01em; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.i { flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- каркас ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; font-weight: 700; font-size: 16px; }
.brand:hover { color: #fff; text-decoration: none; }
.brand-logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: #fff; padding: 4px; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--sidebar-text); letter-spacing: .02em; }
.nav { padding: 6px 10px 16px; display: flex; flex-direction: column; gap: 2px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f93a6; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; }
.nav a:hover { background: var(--sidebar-2); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(27, 118, 133, .45); color: #fff; }
.nav a.active .i { color: #6cc6d2; }
.nav .count { margin-left: auto; background: #6cc6d2; color: #002b41; font-size: 11px; font-weight: 700;
  border-radius: 10px; padding: 0 7px; line-height: 18px; }
.sidebar-foot { margin-top: auto; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06); }
.me { display: flex; align-items: center; gap: 10px; padding: 6px; color: #fff; }
.me .muted { color: var(--sidebar-text); font-size: 12px; }
.me a { color: var(--sidebar-text); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: rgba(244, 247, 249, .85); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.search { flex: 1; max-width: 520px; position: relative; }
.search input { width: 100%; padding: 9px 12px 9px 36px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); font: inherit; }
.search .i { position: absolute; left: 11px; top: 11px; color: var(--muted); }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1480px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* ---------- карточки ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.g-side { grid-template-columns: 340px minmax(0, 1fr); }

.kpi { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.kpi .hint { font-size: 12px; color: var(--muted); }
.kpi .hint.bad { color: var(--red); font-weight: 600; }
.kpi::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%;
  background: var(--brand-50); }
.kpi .label .i { color: var(--brand); position: relative; z-index: 1; }

/* ---------- кнопки и формы ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 500 14px/1.2 var(--font); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); color: #fff; }
.btn-danger { color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: var(--red-bg); color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-icon { padding: 7px; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-btn:hover { color: var(--brand); }
.dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; }

label { font-weight: 500; font-size: 13px; color: var(--text-2); }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], input[type=date],
input[type=datetime-local], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); font: 14px/1.4 var(--font); color: var(--text); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(27, 118, 133, .2); }
select[multiple] { min-height: 110px; }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 16px; height: 16px; vertical-align: -3px; }
input[type=file] { font: inherit; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.wide { grid-column: 1 / -1; }
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err, .errorlist { color: var(--red); font-size: 12px; margin: 0; padding: 0; list-style: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 6px; }
.choices-inline { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.choices-inline label { font-weight: 400; color: var(--text); display: flex; gap: 6px; align-items: center; }
.choices-inline ul, .choices-inline div { list-style: none; padding: 0; margin: 0; display: contents; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.filters input, .filters select { width: auto; min-width: 150px; padding: 7px 10px; }
.filters input[type=search] { min-width: 240px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
tbody tr:hover { background: #f5fafb; }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- бейджи, аватары ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-violet { background: var(--violet-bg); color: var(--violet); }
.b-teal { background: var(--teal-bg); color: var(--teal); }
.b-gray { background: var(--gray-bg); color: var(--text-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; color: #fff; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #cde7ea, #9fd1d8); color: #003c5a; font-weight: 700; font-size: 12px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.person { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* ---------- сообщения ---------- */
.messages { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.msg { padding: 10px 14px; border-radius: 10px; border: 1px solid; font-weight: 500; }
.msg.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.msg.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.msg.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.msg.info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-600); }

/* ---------- списки, лента ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: center; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty .i { display: block; margin: 0 auto 8px; color: var(--border-strong); }
.timeline { list-style: none; margin: 0; padding: 0 18px; }
.timeline li { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border-bottom: 0; }
.tl-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand); }
.tl-icon.call { background: var(--green-bg); color: var(--green); }
.tl-icon.email { background: var(--blue-bg); color: var(--blue); }
.tl-icon.meeting { background: var(--violet-bg); color: var(--violet); }
.tl-icon.message { background: var(--teal-bg); color: var(--teal); }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-text { white-space: pre-wrap; margin-top: 4px; }
audio { width: 100%; max-width: 420px; height: 36px; margin-top: 6px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs a { padding: 12px 12px 10px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .n { font-size: 11px; background: var(--gray-bg); border-radius: 8px; padding: 0 6px; margin-left: 4px; color: var(--text-2); }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; word-break: break-word; }

/* ---------- канбан ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.k-col { flex: 0 0 272px; background: #eaf0f3; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 210px); }
.k-head { padding: 12px 12px 8px; border-top: 3px solid var(--c, var(--brand)); border-radius: var(--radius) var(--radius) 0 0; }
.k-head .t { display: flex; justify-content: space-between; font-weight: 650; }
.k-head .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.k-list { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 80px; flex: 1; }
.k-card { background: var(--surface); border-radius: 10px; padding: 10px 12px; border: 1px solid var(--border); box-shadow: var(--shadow); cursor: grab; }
.k-card:hover { border-color: var(--accent); }
.k-card .t { font-weight: 600; color: var(--text); display: block; }
.k-card .c { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.k-card .f { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.k-card .amt { font-weight: 700; color: var(--text); }
.k-card.overdue { border-left: 3px solid var(--red); }
.k-ghost { opacity: .4; background: var(--brand-50); }
.k-drag { transform: rotate(2deg); box-shadow: var(--shadow-lg); }

/* ---------- воронка и полосы ---------- */
.funnel-row { display: grid; grid-template-columns: 150px 1fr 110px; gap: 12px; align-items: center; padding: 6px 0; }
.bar { height: 10px; border-radius: 6px; background: var(--gray-bg); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: var(--c, var(--brand)); }
.progress { height: 6px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); }
.stars { color: #f59e0b; letter-spacing: 1px; }

/* ---------- выпадающее меню уведомлений ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: 46px; width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); display: none; overflow: hidden; z-index: 50; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu .list > li { padding: 10px 14px; align-items: flex-start; }
.dropdown-menu .unread { background: #eef7f8; }

.pagination { display: flex; gap: 6px; align-items: center; justify-content: space-between; padding: 12px 18px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }

/* ---------- вход ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 10% 10%, #1b7685 0%, #003c5a 45%, #002b41 75%); color: #e6f2f5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-hero h1 { font-size: 34px; color: #fff; max-width: 460px; margin-top: 24px; }
.auth-hero p { color: #b8d8de; max-width: 440px; font-size: 15px; }
.waves { position: absolute; left: 0; right: 0; bottom: 0; opacity: .35; }
.auth-form { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-form form { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }

/* ---------- адаптив ---------- */
@media (max-width: 1200px) { .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main, .g-side { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 10px 16px; }
  .content { padding: 18px 16px 40px; }
  .g-2, .g-3, .form-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; } .auth-hero { display: none; }
  .dropdown-menu { width: calc(100vw - 32px); right: -60px; }
  .funnel-row { grid-template-columns: 100px 1fr 80px; }
}
@media (max-width: 560px) { .g-4 { grid-template-columns: 1fr; } .dl { grid-template-columns: 1fr; } }
