/* ============================================================
   Дизайн-система «Отдел продаж» — светлая/тёмная тема, без зависимостей.
   ============================================================ */
:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F1F5F9;
  --surface-3: #E2E8F0;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-2: #475569;
  --text-3: #94A3B8;
  --accent: #2563EB;
  --accent-weak: #DBEAFE;
  --accent-ink: #1D4ED8;
  --green: #16A34A;
  --green-weak: #DCFCE7;
  --amber: #D97706;
  --amber-weak: #FEF3C7;
  --red: #DC2626;
  --red-weak: #FEE2E2;
  --violet: #7C3AED;
  --violet-weak: #EDE9FE;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #0F172A;
  --surface-2: #131C30;
  --surface-3: #1E293B;
  --border: #1E293B;
  --border-strong: #334155;
  --text: #E2E8F0;
  --text-2: #94A3B8;
  --text-3: #64748B;
  --accent: #3B82F6;
  --accent-weak: #1E293B;
  --accent-ink: #93C5FD;
  --green-weak: #102A1C;
  --amber-weak: #2A2110;
  --red-weak: #2A1414;
  --violet-weak: #1E1733;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 6px 18px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 50px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- Каркас ---------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------------- Сайдбар ---------------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  gap: 4px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--accent), var(--violet));
  color: #fff; display: grid; place-items: center; font-size: 20px; font-weight: 800;
  box-shadow: var(--shadow);
}
.brand-title { font-weight: 800; font-size: 15px; line-height: 1.1; }
.brand-sub { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; font-size: 13.5px;
  border: none; background: transparent; text-align: left; width: 100%;
  transition: background .12s, color .12s;
}
.nav-item .ico { width: 19px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-weak); color: var(--accent-ink); }
.nav-item .nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 10px; min-width: 18px; text-align: center;
}
.nav-sep { height: 1px; background: var(--border); margin: 8px 6px; }

.user-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 8px;
  border-top: 1px solid var(--border); margin-top: 6px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #34D399, var(--accent)); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-name { font-weight: 700; font-size: 13px; }
.user-status { font-size: 11px; color: var(--green); display: flex; align-items: center; gap: 5px; }
.user-status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); }

/* ---------------- Основная область ---------------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.topbar {
  height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: relative;
}
.search { flex: 1; max-width: 540px; position: relative; }
.search input {
  width: 100%; height: 40px; padding: 0 14px 0 38px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 13.5px; outline: none;
  transition: border .12s, background .12s;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search::before {
  content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 13px; opacity: .6;
}
.search-results {
  position: absolute; top: 46px; left: 0; right: 0; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto; padding: 6px; display: none;
}
.search-results.open { display: block; }
.search-results .sr { padding: 9px 11px; border-radius: 8px; cursor: pointer; display: flex; gap: 9px; align-items: center; }
.search-results .sr:hover { background: var(--surface-2); }
.search-results .sr .sr-tag {
  font-size: 10px; font-weight: 700; color: var(--text-3); text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; flex: none;
}
.btn {
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  font-weight: 700; font-size: 13.5px; display: inline-flex; align-items: center; gap: 7px;
  background: var(--accent); color: #fff; transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-3); filter: none; }
.btn.mini { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2); display: grid; place-items: center;
  font-size: 17px; position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 7px; right: 8px; width: 9px; height: 9px;
  background: var(--red); border-radius: 50%; border: 2px solid var(--surface);
}

.view { flex: 1; overflow-y: auto; padding: 24px; }
.view-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.view-head h1 { font-size: 22px; }
.view-head .sub { color: var(--text-3); font-size: 13px; }
.view-head .spacer { flex: 1; }

/* ---------------- Pills / статусные плашки ---------------- */
.pill {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
}
.pill-muted { background: var(--surface-3); color: var(--text-2); }
.pill-on, .pill-green { background: var(--green-weak); color: var(--green); }
.pill-off { background: var(--surface-3); color: var(--text-3); }
.pill-accent { background: var(--accent-weak); color: var(--accent-ink); }
.pill-amber { background: var(--amber-weak); color: var(--amber); }
.pill-red { background: var(--red-weak); color: var(--red); }
.pill-violet { background: var(--violet-weak); color: var(--violet); }

/* ---------------- Сетка дашборда ---------------- */
.grid { display: grid; gap: 16px; }
.dash-grid { grid-template-columns: repeat(12, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.card-head h3 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-head .hint { color: var(--text-3); font-size: 12px; font-weight: 600; }
.col-12 { grid-column: span 12; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
@media (max-width: 1100px) {
  .col-8, .col-6, .col-5, .col-4, .col-3 { grid-column: span 12; }
}

/* KPI-метрики */
.metrics { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 1100px) { .metrics { grid-template-columns: repeat(3, 1fr); } }
.metric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.metric .v { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.metric .k { font-size: 12px; color: var(--text-3); font-weight: 600; margin-top: 2px; }
.metric.alert { border-color: var(--red); background: var(--red-weak); }
.metric.alert .v { color: var(--red); }

/* Графический конвейер на дашборде */
.pipe-strip { display: flex; gap: 10px; }
.pipe-stage {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; text-align: center; cursor: pointer; background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border .12s, transform .06s, box-shadow .12s;
}
.pipe-stage:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.pipe-stage .pv { font-size: 24px; font-weight: 800; color: var(--text); }
.pipe-stage .pk { font-size: 11px; color: var(--text-2); font-weight: 600; margin-top: 3px; }
.pipe-stage .bar { height: 4px; border-radius: 4px; background: var(--accent); margin-top: 8px; opacity: .85; }

/* Срочные дедлайны — карточки со счётчиком дней */
.urg-list { display: flex; flex-direction: column; gap: 8px; }
.urg-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-left: 3px solid var(--text-3);
  border-radius: var(--radius-sm); background: var(--surface); transition: border-color .12s, background .12s;
}
.urg-item:hover { background: var(--surface-2); }
.urg-item.dl-red { border-left-color: var(--red); }
.urg-item.dl-amber { border-left-color: var(--amber); }
.urg-item.dl-green { border-left-color: var(--green); }
.urg-days { flex: none; width: 50px; text-align: center; line-height: 1.05; }
.urg-days b { font-size: 22px; font-weight: 800; display: block; }
.urg-days span { font-size: 10px; color: var(--text-3); font-weight: 600; }
.urg-item.dl-red .urg-days b { color: var(--red); }
.urg-item.dl-amber .urg-days b { color: var(--amber); }
.urg-item.dl-green .urg-days b { color: var(--green); }
.urg-main { min-width: 0; flex: 1; }
.urg-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.urg-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Списки строк */
.row-list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  cursor: pointer; transition: border .12s, background .12s;
}
.row:hover { border-color: var(--border-strong); background: var(--surface-2); }
.row .r-main { min-width: 0; flex: 1; }
.row .r-title { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.row .r-right { flex: none; text-align: right; }
.empty { color: var(--text-3); font-size: 13px; padding: 18px; text-align: center; }
.deadline-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dl-red { background: var(--red); } .dl-amber { background: var(--amber); } .dl-green { background: var(--green); } .dl-grey { background: var(--text-3); }

/* Щит надёжности */
.shield { width: 44px; height: 44px; border-radius: 12px; flex: none; display: grid; place-items: center; font-weight: 800; font-size: 14px; color: #fff; }
.shield.hi { background: var(--green); }
.shield.mid { background: var(--amber); }
.shield.lo { background: var(--red); }
.shield-sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }
.rel { font-weight: 700; }
.rel.hi { color: var(--green); } .rel.mid { color: var(--amber); } .rel.lo { color: var(--red); }

/* Кнопки быстрых действий */
.quick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.quick {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px;
  background: var(--surface-2); text-align: left; font-weight: 700; font-size: 13px; color: var(--text);
  display: flex; flex-direction: column; gap: 6px; transition: border .12s, transform .06s;
}
.quick:hover { border-color: var(--accent); transform: translateY(-2px); }
.quick .qi { font-size: 22px; }
.quick .qd { font-size: 11.5px; color: var(--text-3); font-weight: 500; }

/* ---------------- Канбан ---------------- */
.kanban { display: flex; gap: 14px; align-items: flex-start; overflow-x: auto; padding-bottom: 8px; }
.kcol { width: 290px; flex: none; display: flex; flex-direction: column; }
.kcol-head {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; margin-bottom: 10px;
  border-radius: var(--radius-sm); font-weight: 700; font-size: 13px; background: var(--surface);
  border: 1px solid var(--border);
}
.kcol-head .cnt { margin-left: auto; color: var(--text-3); font-weight: 700; }
.kcol-head .swatch { width: 9px; height: 9px; border-radius: 3px; }
.kcol-body {
  display: flex; flex-direction: column; gap: 10px; min-height: 80px;
  border-radius: var(--radius-sm); padding: 4px; transition: background .12s;
}
.kcol-body.drag-over { background: var(--accent-weak); outline: 2px dashed var(--accent); }
.kcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; box-shadow: var(--shadow-sm); cursor: grab; transition: box-shadow .12s, transform .06s;
}
.kcard:hover { box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard .kc-top { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; }
.kcard .kc-src {
  font-size: 10px; font-weight: 700; color: var(--text-2); background: var(--surface-3);
  border-radius: 6px; padding: 2px 7px; white-space: nowrap;
}
.kcard .kc-cust { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 12px; margin: 6px 0; }
.kcard .kc-bldg { width: 24px; height: 24px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font-size: 12px; flex: none; }
.kcard .kc-title { font-weight: 600; font-size: 13px; line-height: 1.3; }
.kcard .kc-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.kcard .kc-agents { margin-left: auto; display: flex; }
.kc-agent {
  width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; margin-left: -6px; border: 2px solid var(--surface);
}
.dl-bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 8px; }
.dl-bar > span { display: block; height: 100%; border-radius: 4px; }

/* ---------------- Side-panel (паспорт) ---------------- */
.sidepanel-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 80; opacity: 0; pointer-events: none; transition: opacity .18s; }
.sidepanel-backdrop.open { opacity: 1; pointer-events: auto; }
.sidepanel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 94vw; z-index: 90;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.sidepanel.open { transform: translateX(0); }
.sp-head { padding: 18px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 12px; }
.sp-head h2 { font-size: 17px; line-height: 1.25; }
.sp-head .close { margin-left: auto; }
.sp-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.sp-tabs { display: flex; gap: 4px; padding: 0 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.sp-tab { padding: 11px 13px; font-weight: 700; font-size: 12.5px; color: var(--text-3); border: none; background: none; border-bottom: 2px solid transparent; }
.sp-tab.active { color: var(--accent-ink); border-bottom-color: var(--accent); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }

/* Таймлайн истории */
.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 4px; }
.tl-item { display: flex; gap: 11px; padding-bottom: 16px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 9px; top: 20px; bottom: 0; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 20px; height: 20px; border-radius: 50%; flex: none; background: var(--accent-weak); border: 2px solid var(--accent); display: grid; place-items: center; font-size: 9px; color: var(--accent-ink); z-index: 1; }
.tl-body .tl-t { font-weight: 600; font-size: 13px; }
.tl-body .tl-s { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------------- Почтовый клиент (RFQ) ---------------- */
.mail { display: grid; grid-template-columns: 290px 1fr 300px; gap: 0; height: calc(100vh - var(--topbar-h) - 110px);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
@media (max-width: 1100px) { .mail { grid-template-columns: 1fr; height: auto; } }
.mail-col { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.mail-col + .mail-col { border-left: 1px solid var(--border); }
.mail-col-head { padding: 12px 14px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; flex: none; }
.mail-list { overflow-y: auto; }
.mail-thread { padding: 11px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.mail-thread:hover, .mail-thread.active { background: var(--surface-2); }
.mail-thread .mt-t { font-weight: 600; font-size: 13px; }
.mail-thread .mt-s { font-size: 11.5px; color: var(--text-3); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.mail-body { padding: 18px; overflow-y: auto; }
.mail-msg { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; margin-bottom: 12px; background: var(--surface); }
.mail-msg .mm-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); margin-bottom: 8px; }
.verify { padding: 16px; overflow-y: auto; }
.verify-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.verify-item .vi-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.match-ico { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 12px; flex: none; }
.match-green { background: var(--green); } .match-yellow { background: var(--amber); } .match-red { background: var(--red); }

/* ---------------- Документы ---------------- */
.doc-group-title { font-size: 12px; font-weight: 700; color: var(--text-3); text-transform: uppercase; margin: 14px 0 6px; }
.doc-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; }
.doc-item:hover { border-color: var(--border-strong); }
.doc-item .di-ico { font-size: 18px; }
.doc-item .di-main { flex: 1; min-width: 0; }
.doc-item .di-t { font-weight: 600; font-size: 13px; }
.doc-item .di-s { font-size: 11.5px; color: var(--text-3); }
.downloads { display: flex; gap: 6px; }
.dl { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 7px; background: var(--accent-weak); color: var(--accent-ink); border: 1px solid transparent; }
.dl:hover { background: var(--accent); color: #fff; }

/* ---------------- Task Board ---------------- */
.tasks-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1100px) { .tasks-grid { grid-template-columns: repeat(2, 1fr); } }
.tlane-head { font-weight: 700; font-size: 13px; margin-bottom: 10px; display: flex; gap: 8px; align-items: center; }
.tcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow-sm); cursor: pointer; }
.tcard:hover { border-color: var(--border-strong); }
.tcard.needs-human { border: 1.5px solid var(--amber); background: var(--amber-weak); }
.tcard .tc-cmd { font-weight: 600; font-size: 13px; line-height: 1.35; }
.tcard .tc-meta { font-size: 11px; color: var(--text-3); margin-top: 7px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.approve-row { display: flex; gap: 8px; margin-top: 10px; }

/* ---------------- Аналитика ---------------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 44px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { height: 22px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--accent); min-width: 2px; }
.bar-row .bv { text-align: right; font-weight: 700; }
.price-rec { text-align: center; padding: 10px 0; }
.price-rec .big { font-size: 40px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent-ink); }
.donut-legend { display: flex; flex-direction: column; gap: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-dot { width: 11px; height: 11px; border-radius: 3px; }

/* ---------------- Чат-док ---------------- */
.chat-fab {
  position: fixed; bottom: 24px; right: 24px; width: 58px; height: 58px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 26px; box-shadow: var(--shadow-lg); border: none; z-index: 70; display: grid; place-items: center;
}
.chat-fab .dot { position: absolute; top: 4px; right: 4px; min-width: 18px; height: 18px; padding: 0 4px; background: var(--red); border-radius: 9px; border: 2px solid var(--accent); font-size: 10px; display: grid; place-items: center; color: #fff; font-weight: 800; }
.chatdock {
  position: fixed; bottom: 24px; right: 24px; width: 380px; max-width: 92vw; height: 560px; max-height: 84vh;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  z-index: 75; display: none; flex-direction: column; overflow: hidden;
}
.chatdock.open { display: flex; }
.chat-head { background: var(--accent); color: #fff; padding: 13px 16px; display: flex; align-items: center; gap: 10px; }
.chat-head .ch-av { width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 16px; }
.chat-head .ch-name { font-weight: 700; }
.chat-head .ch-sub { font-size: 11px; opacity: .85; }
.chat-head .close { margin-left: auto; background: rgba(255,255,255,.18); color: #fff; border: none; width: 28px; height: 28px; border-radius: 8px; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 88%; }
.msg .bubble { padding: 9px 12px; border-radius: 13px; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow-sm); }
.msg.user { align-self: flex-end; }
.msg.user .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .who { font-size: 10px; color: var(--text-3); margin-bottom: 3px; font-weight: 700; }
.msg .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 5px; }
.tag { font-size: 9.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); }
.tag.llm { background: var(--violet-weak); color: var(--violet); }
.tag.rule { background: var(--accent-weak); color: var(--accent-ink); }
.chat-composer { display: flex; gap: 8px; padding: 11px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-composer input { flex: 1; height: 38px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text); outline: none; }
.chat-composer input:focus { border-color: var(--accent); }
.chat-composer button { width: 38px; height: 38px; border-radius: 10px; border: none; background: var(--accent); color: #fff; font-size: 16px; }

/* ---------------- Модал / визард ---------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: none; place-items: center; }
.modal-backdrop.open { display: grid; }
.modal { width: 480px; max-width: 94vw; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 9px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text); font-family: inherit; font-size: 13.5px; outline: none;
}
.field textarea { min-height: 70px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { font-size: 12px; padding: 7px 11px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }

/* ---------------- Onboarding tour ---------------- */
.tour-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 110; display: none; place-items: center; }
.tour-backdrop.open { display: grid; }
.tour-card { width: 440px; max-width: 92vw; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 26px; text-align: center; }
.tour-card .ti { font-size: 46px; }
.tour-card h3 { font-size: 19px; margin: 12px 0 8px; }
.tour-card p { color: var(--text-2); font-size: 14px; margin: 0 0 18px; }
.tour-dots { display: flex; gap: 7px; justify-content: center; margin-bottom: 18px; }
.tour-dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); transition: width .15s; }
.tour-dots span.on { background: var(--accent); width: 22px; border-radius: 5px; }
.tour-foot { display: flex; justify-content: space-between; align-items: center; }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text); color: var(--surface); padding: 11px 18px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); animation: toastin .2s; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }

/* Уведомления-поповер */
.notif-pop { position: absolute; top: 52px; right: 22px; width: 340px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 60; display: none; }
.notif-pop.open { display: block; }
.notif-pop .np-head { padding: 11px 15px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: space-between; gap: 8px; position: sticky; top: 0; background: var(--surface); }
.np-count { background: var(--red); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 10px; }
.np-clear { border: none; background: none; color: var(--accent-ink); font-weight: 700; font-size: 11.5px; padding: 2px 4px; }
.np-clear:hover { text-decoration: underline; }
.notif-pop .np-item { padding: 11px 15px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; font-size: 12.5px; cursor: pointer; }
.notif-pop .np-item:hover { background: var(--surface-2); }
.notif-pop .np-item:last-child { border-bottom: none; }
.notif-pop .np-item.np-read { opacity: .5; }
.notif-ico { font-size: 16px; }

/* Загрузка договора юристу */
.upload-zone { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); }
.law-result { margin-top: 12px; }
.law-verdict { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.law-verdict.red { border-color: var(--red); background: var(--red-weak); }
.law-verdict.yellow { border-color: var(--amber); background: var(--amber-weak); }
.law-verdict.green { border-color: var(--green); background: var(--green-weak); }
.law-verdict .lv-head { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.law-verdict .lv-cap { font-size: 11.5px; font-weight: 700; color: var(--text-2); margin-top: 10px; }
.law-verdict .lv-list { margin: 6px 0 0; padding-left: 20px; font-size: 12.5px; }
.law-verdict .lv-list li { margin-bottom: 3px; }
.law-verdict .lv-note { margin-top: 6px; }

/* ---------------- Рендер markdown (вывод агентов: юрист, чат) ---------------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 8px; }
.md .md-h { font-size: 14px; font-weight: 800; margin: 12px 0 6px; }
.md .md-list { margin: 6px 0; padding-left: 20px; }
.md .md-list li { margin-bottom: 3px; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md code { background: var(--surface-3); padding: 1px 5px; border-radius: 5px; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.md .md-table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; display: block; overflow-x: auto; }
.md .md-table th, .md .md-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.md .md-table th { background: var(--surface-2); font-weight: 700; white-space: nowrap; }
.md .md-table tr:nth-child(even) td { background: var(--surface-2); }
/* В чат-пузыре markdown рендерится как HTML — отключаем pre-wrap, чтобы не было двойных отступов */
.msg.bot .bubble.md { white-space: normal; }

.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 8px; }
.gap-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: var(--surface); color: var(--text-2); padding: 7px 13px; font-weight: 700; font-size: 12.5px; }
.seg button.on { background: var(--accent); color: #fff; }
