/* VOVO - дашборд отдела продаж.
   Токены из design/tokens.json (макет Figma «VOVO · Продажи»). Светлая тема, теней нет,
   глубина строится рамкой 1px и разницей фона с поверхностью. Шрифт - системный стек. */

:root {
  color-scheme: light;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #fbfbfc;
  --surface-3: #f2f4f7;
  --line: #e6e9ee;
  --line-soft: #eef0f4;

  --ink: #1b2028;
  --ink-2: #68727e;
  --muted: #8d96a0;

  --accent: #fa8116;
  --accent-ink: #ad4704;
  --accent-soft: #fff0e2;
  --accent-soft-2: #ffdcb9;

  --good: #237454;
  --good-soft: #eaf6ef;
  --bad: #bf4b41;
  --bad-soft: #fff0ed;
  --dark: #23272d;

  /* статусные цвета карты и индикаторов (палитра dataviz, только рядом со словом) */
  --st-good: #0ca30c;
  --st-warn: #fab219;
  --st-crit: #d03b3b;
  --st-neutral: #898781;

  /* ряды данных: оранжевый VOVO (первый) и синий слот палитры dataviz (второй) */
  --s1: #fa8116;
  --s2: #2a78d6;
  --grid: #e6e9ee;
  --axis: #c9ced6;

  --r-card: 18px;
  --r: 10px;
  --sidebar-w: 224px;
  --gap: 24px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { max-width: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 500 13px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--s2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; }

/* ==================== каркас ==================== */

.app { display: flex; min-height: 100vh; align-items: flex-start; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 32px 20px 24px;
}

.brand { display: block; padding-left: 12px; }
.brand-word {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.brand-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); display: inline-block; margin-left: 4px; margin-bottom: -10px;
}
.brand-sub { color: var(--muted); font-size: 12px; font-weight: 400; padding: 6px 0 0 12px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 32px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 12px;
  border-radius: var(--r);
  color: var(--ink-2);
  font-size: 14px; font-weight: 500; line-height: 20px;
  background: none; border: 0; width: 100%; text-align: left;
  font-family: inherit; cursor: pointer;
}
.nav-item:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.nav-item svg { flex: 0 0 20px; width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); }
.nav-item.active:hover { background: var(--accent-soft); }
.nav-short { display: none; }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 24px; }
.side-stat {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r);
  background: none; border: 0; width: 100%; text-align: left;
  font-family: inherit; font-size: 12px; font-weight: 400; color: var(--muted); cursor: pointer;
  line-height: 1.35;
}
.side-stat:hover { background: var(--surface-3); }
.side-stat span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--st-neutral); display: inline-block; }
.dot.good { background: var(--st-good); }
.dot.warn { background: var(--st-warn); }
.dot.bad { background: var(--st-crit); }
.dot.idle { background: var(--st-neutral); }

.main { flex: 1; min-width: 0; padding: 28px 32px 24px; max-width: 1376px; }

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: var(--gap);
}
.topbar h1 { font-size: 32px; line-height: 46px; font-weight: 600; letter-spacing: -0.8px; }
.page-sub { margin: 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 18px; }
.page-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ==================== базовые элементы ==================== */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 18px 22px;
}
.card.hl { border-color: var(--accent-soft-2); }
.card h2 { font-size: 18px; line-height: 26px; }
.card h3 { font-size: 15px; line-height: 22px; }
.card-sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-body { margin-top: 14px; }

.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-s { display: flex; flex-direction: column; gap: 12px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 12px; }

.muted { color: var(--muted); }
.small { font-size: 12px; font-weight: 400; }
.wrap { white-space: normal; }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  font-family: inherit; font-size: 13px; font-weight: 500; line-height: 20px;
  height: 40px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #ec7710; border-color: #ec7710; }
.btn.small { height: 32px; padding: 0 10px; font-size: 12px; }
.btn.active { background: var(--accent-soft); border-color: var(--accent-soft); color: var(--accent-ink); }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn[disabled] { opacity: 0.5; cursor: default; }

input[type="text"], input[type="number"], input[type="date"], input[type="month"], select, textarea {
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--ink);
  height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); max-width: 100%;
}
textarea { height: auto; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
input.w-s { width: 108px; }
input.w-m { width: 150px; }
input.err { border-color: var(--bad); background: var(--bad-soft); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.fields { display: flex; gap: 12px; flex-wrap: wrap; }

/* ==================== плашки ==================== */

.note {
  display: flex; gap: 10px; align-items: flex-start;
  border-radius: var(--r); padding: 10px 12px; font-size: 13px; font-weight: 500;
  background: var(--surface-3); color: var(--ink-2);
}
.note.warn { background: var(--accent-soft); color: var(--accent-ink); }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.good { background: var(--good-soft); color: var(--good); }
.note .ico { flex: 0 0 16px; margin-top: 1px; }
.note a { color: inherit; text-decoration: underline; }
.note .btn { margin-left: auto; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; line-height: 18px;
  padding: 3px 9px; border-radius: 100px;
  background: var(--surface-3); color: var(--ink-2);
}
.badge.warn { background: var(--accent-soft); color: var(--accent-ink); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.good { background: var(--good-soft); color: var(--good); }

/* ==================== KPI ==================== */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 18px 22px; min-width: 0; display: flex; flex-direction: column; gap: 7px;
}
.kpi.hl { border-color: var(--accent-soft-2); }
.kpi .k-label { font-size: 13px; font-weight: 500; color: var(--ink-2); line-height: 19px; }
.kpi .k-value { font-size: 32px; font-weight: 600; letter-spacing: -0.9px; line-height: 40px; }
.kpi .k-delta { font-size: 12px; font-weight: 500; display: flex; align-items: center; gap: 5px; color: var(--muted); }
.kpi .k-delta.up { color: var(--good); }
.kpi .k-delta.down { color: var(--bad); }
.kpi .k-foot { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 17px; }
/* прогноз показывается только у незакрытого периода: это не факт, поэтому отделён линией и приглушён */
.kpi .k-forecast {
  font-size: 12px; font-weight: 500; color: var(--accent-ink); line-height: 17px;
  margin-top: 2px; padding-top: 6px; border-top: 1px dashed var(--border);
}
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.section-head .section-title { margin: 0; }
.section-note { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 17px; }

/* ==================== команда ==================== */

.team { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.person { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px 22px; min-width: 0; }
.person .p-name { font-size: 15px; font-weight: 600; line-height: 22px; }
.person .p-role { font-size: 12px; font-weight: 400; color: var(--muted); }
.p-nums { display: flex; gap: 26px; margin-top: 14px; }
.p-num .n { font-size: 32px; font-weight: 600; line-height: 40px; letter-spacing: -0.9px; }
.p-num .l { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.p-rows { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 5px; }
.p-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-2); }
.p-row b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.p-plan { margin-top: 14px; }
.p-plan .l { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.bar { height: 6px; border-radius: 100px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 100px; background: var(--accent); }
.bar > i.done { background: var(--good); }
.p-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* ==================== воронка коротко ==================== */

.funnel-short { display: flex; align-items: stretch; gap: 8px; flex-wrap: wrap; }
.fstep {
  flex: 1 1 140px; min-width: 0;
  background: var(--bg); border-radius: var(--r); padding: 12px 14px;
}
.fstep .n { font-size: 26px; font-weight: 600; letter-spacing: -0.7px; line-height: 34px; }
.fstep .l { font-size: 12px; font-weight: 500; color: var(--ink-2); }
.farrow { display: flex; align-items: center; color: var(--axis); font-size: 16px; }

/* ==================== инсайты ==================== */

.insights { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.insights li { border-left: 3px solid var(--accent-soft-2); padding: 1px 0 1px 12px; }
.insights .i-title { font-weight: 600; font-size: 13px; line-height: 19px; }
.insights .i-text { font-size: 13px; font-weight: 400; color: var(--ink-2); margin-top: 3px; line-height: 19px; }
.insights .i-act { font-size: 12px; font-weight: 500; color: var(--accent-ink); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }

.ask { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; min-width: 0; }

.md { font-size: 13px; font-weight: 400; color: var(--ink-2); }
.md p { margin: 0 0 8px; }
.md ul, .md ol { margin: 0 0 8px; padding-left: 20px; }
.md li { margin-bottom: 3px; }
.md h3, .md h4, .md h5, .md h6 { font-size: 13px; font-weight: 600; margin: 10px 0 5px; color: var(--ink); }
.md code { background: var(--surface-3); border-radius: 4px; padding: 1px 4px; font-size: 12px; }
.md pre { background: var(--surface-3); border-radius: var(--r); padding: 10px; overflow-x: auto; }
.md strong { color: var(--ink); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }

/* ==================== таблицы ==================== */

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  font-size: 11px; font-weight: 500; line-height: 16px;
  color: var(--muted); text-align: left; padding: 0 10px 8px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.tbl td { padding: 0 10px; height: 40px; font-weight: 500; white-space: nowrap; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl th.n, table.tbl td.n { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.wrap { white-space: normal; min-width: 160px; }
table.tbl td.strong { font-weight: 600; }
table.tbl tr.total td { font-weight: 600; border-top: 1px solid var(--line); background: var(--surface-2); }
table.tbl tr.dim td { color: var(--muted); }
table.tbl tr.clickable { cursor: pointer; }
table.tbl tr.clickable:hover td { background: var(--surface-2); }
table.tbl td .cell-note { font-size: 11px; font-weight: 400; color: var(--muted); white-space: nowrap; }
table.tbl td.tall { height: auto; padding-top: 12px; padding-bottom: 12px; }
table.tbl td.pad { padding: 0; }
.sub-table { background: var(--bg); border-radius: var(--r); padding: 12px 14px; margin: 4px 0 10px; }
.sub-table h4 { font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 12px 0 4px; }
.sub-table h4:first-child { margin-top: 0; }
.tbl-foot { font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 10px; }

details.twin { margin-top: 12px; }
details.twin > summary { cursor: pointer; font-size: 12px; color: var(--ink-2); padding: 4px 0; }
details.twin[open] > summary { margin-bottom: 8px; }

/* ==================== графики ==================== */

.chart-box { position: relative; width: 100%; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 10px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 7px; }

/* ==================== вкладки внутри раздела ==================== */

.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 4px; }

/* ==================== карта ==================== */

#map { height: 70vh; min-height: 340px; width: 100%; border-radius: var(--r-card); border: 1px solid var(--line); z-index: 0; }
.map-legend { display: flex; gap: 8px; flex-wrap: wrap; }
.leg {
  display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 500;
  border: 1px solid var(--line); background: var(--surface); border-radius: 100px;
  height: 32px; padding: 0 12px; cursor: pointer; font-family: inherit; color: var(--ink-2);
}
.leg .sw { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(27,32,40,0.14); }
.leg.off { opacity: 0.45; }
.leg b { font-variant-numeric: tabular-nums; color: var(--ink); }
.popup-t { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.popup-r { font-size: 12px; font-weight: 400; color: var(--ink-2); line-height: 17px; }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font); }
.leaflet-container { font-family: var(--font); }

/* ==================== скелетоны, пустое, ошибки ==================== */

@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk {
  background: linear-gradient(90deg, #edeff3 25%, #f6f7f9 37%, #edeff3 63%);
  background-size: 300% 100%;
  animation: sk 1.3s ease-in-out infinite;
  border-radius: var(--r);
}
.sk-card { height: 132px; border-radius: var(--r-card); }
.sk-line { height: 13px; margin-bottom: 10px; }
.sk-block { height: 260px; border-radius: var(--r-card); }
.sk-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.empty { color: var(--muted); font-size: 13px; font-weight: 400; padding: 8px 0; }

/* ==================== адаптив ==================== */

@media (max-width: 1180px) {
  .team { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1000px) {
  .kpis, .sk-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app { display: block; }
  .sidebar {
    width: auto; flex: none; height: auto; position: sticky; top: 0; z-index: 500;
    border-right: 0; border-bottom: 1px solid var(--line);
    flex-direction: row; align-items: center; gap: 12px;
    padding: 10px 16px; overflow-x: auto;
  }
  .brand { padding-left: 0; }
  .brand-word { font-size: 22px; }
  .brand-sub { display: none; }
  .nav { flex-direction: row; margin-top: 0; gap: 2px; }
  .nav-item { height: 36px; padding: 0 10px; white-space: nowrap; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; padding-top: 0; }
  .side-stat { width: auto; white-space: nowrap; }
  .main { padding: 20px 16px 32px; }
  .team { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .team { grid-template-columns: minmax(0, 1fr); }
  .topbar h1 { font-size: 24px; line-height: 32px; }
  .side-stat-text { display: none; }
}

@media (max-width: 520px) {
  .main { padding: 16px 12px 28px; }
  .card { padding: 14px 14px; }
  .kpi { padding: 14px 14px; }
  .kpi .k-value { font-size: 26px; line-height: 32px; }
  .person { padding: 14px 14px; }
  .nav-item { gap: 7px; padding: 0 8px; font-size: 12px; }
  .nav-label { display: none; }
  .nav-short { display: inline; }
  .p-nums { gap: 18px; }
  .p-num .n { font-size: 26px; line-height: 32px; }
  .ask-row { flex-direction: column; align-items: stretch; }
  .page-tools .btn { height: 34px; }
}

/* ==================== вход и аккаунты ==================== */

body.locked { overflow: hidden; }
body.locked .app { display: none; }

.login-screen {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  padding: 28px 28px 22px;
  display: flex; flex-direction: column; gap: 4px;
}
.login-card .brand { padding-left: 0; }
/* подпись под логотипом на узком экране прячется в сайдбаре, но на экране входа нужна всегда */
.login-card .brand-sub { display: block; padding: 4px 0 0; }
.login-title { font-size: 22px; line-height: 30px; margin: 18px 0 2px; }
.login-note { font-size: 13px; color: var(--ink-2); margin: 0 0 6px; }
.login-field { display: flex; flex-direction: column; gap: 5px; margin-top: 12px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.login-field input {
  height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: 500 14px/1.4 var(--font);
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-btn { margin-top: 18px; width: 100%; height: 42px; justify-content: center; }
.login-err { color: var(--bad); font-size: 13px; min-height: 18px; margin: 10px 0 0; }
.login-foot { color: var(--muted); font-size: 12px; font-weight: 400; margin: 6px 0 0; line-height: 1.4; }

.side-account { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.side-me {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
  background: none; border: 0; padding: 4px 12px; border-radius: var(--r);
  font-family: inherit; text-align: left; cursor: pointer;
}
.side-me:hover { background: var(--surface-3); }
.side-me-name { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-me-role { font-size: 11px; font-weight: 400; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-out { flex: 0 0 auto; }

@media (max-width: 900px) {
  .side-account { margin-top: 0; padding-top: 0; border-top: 0; border-left: 1px solid var(--line); padding-left: 8px; }
  .side-me-role { display: none; }
}

/* ==================== чат «Поддержка» (helpchat.js) ==================== */

.hc-root { position: fixed; right: 24px; bottom: 24px; z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.hc-root[hidden] { display: none; }

.hc-fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent); color: #fff;
  border: 1px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-family: inherit;
  box-shadow: 0 6px 18px rgba(27, 32, 40, 0.14);
}
.hc-fab:hover { background: #ec7710; border-color: #ec7710; }
.hc-fab.open { background: var(--surface); color: var(--accent-ink); border-color: var(--line); }
.hc-fab-mark { font-size: 24px; font-weight: 700; line-height: 1; }

.hc-panel {
  width: 380px; height: 520px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  box-shadow: 0 10px 30px rgba(27, 32, 40, 0.12);
  display: flex; flex-direction: column; overflow: hidden;
}
.hc-panel[hidden] { display: none; }

.hc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 16px 12px; border-bottom: 1px solid var(--line); }
.hc-title { font-size: 15px; font-weight: 600; color: var(--ink); line-height: 22px; }
.hc-sub { font-size: 12px; font-weight: 400; color: var(--muted); line-height: 18px; }
.hc-close {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: var(--r);
  background: none; border: 0; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; font-family: inherit;
}
.hc-close:hover { background: var(--surface-3); color: var(--ink); }

.hc-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.hc-main[hidden] { display: none; }

.hc-feed { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.hc-msg { max-width: 92%; border-radius: 14px; padding: 9px 12px; font-size: 13px; line-height: 1.45; }
.hc-msg.hc-me { align-self: flex-end; background: var(--accent-soft); color: var(--accent-ink); }
.hc-msg.hc-bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.hc-msg.hc-err { align-self: flex-start; background: var(--bad-soft); color: var(--bad); }
.hc-text { white-space: pre-wrap; }
.hc-msg .md { font-size: 13px; }
.hc-msg .md p:last-child, .hc-msg .md ul:last-child, .hc-msg .md ol:last-child { margin-bottom: 0; }
.hc-meta { margin-top: 6px; font-size: 11px; font-weight: 400; color: var(--muted); }

.hc-typing { display: flex; align-items: center; gap: 4px; }
.hc-typing-text { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
.hc-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: hc-blink 1.2s infinite; }
.hc-dot:nth-child(2) { animation-delay: 0.2s; }
.hc-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes hc-blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .hc-dot { animation: none; opacity: 0.6; } }

.hc-hints { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 10px; }
.hc-hints .btn { font-size: 11px; height: 28px; padding: 0 9px; }

.hc-form { display: flex; gap: 8px; padding: 0 16px 10px; }
.hc-input {
  flex: 1 1 auto; min-width: 0; height: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink);
  font: 500 13px/1.4 var(--font);
}
.hc-input:focus { outline: none; border-color: var(--accent); }
.hc-form .btn { flex: 0 0 auto; }

.hc-foot { display: flex; gap: 6px; padding: 0 12px 12px; border-top: 1px solid var(--line-soft); margin: 0 4px; padding-top: 8px; }

.hc-doc { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.hc-doc[hidden] { display: none; }
.hc-doc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line-soft); }
.hc-doc-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 12px 16px 16px; }
.hc-doc-body .md { font-size: 12px; }
.hc-doc-body table { width: 100%; border-collapse: collapse; font-size: 11px; }
.hc-doc-body td, .hc-doc-body th { border-bottom: 1px solid var(--line-soft); padding: 4px 6px; text-align: left; vertical-align: top; }

/* ==================== карта v2 ==================== */
/* Блок дописан отдельно, чтобы не пересекаться с правками других разделов.
   Сюда идёт всё, что появилось на карте: плитки сводки, панель управления,
   кластеры, расширенный попап и таблицы проблемных адресов. */

.map-tiles {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 12px;
}
.map-tile {
  position: relative; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 2px;
  font-family: inherit; color: inherit;
}
.map-tile.act { cursor: pointer; }
.map-tile.act:hover { border-color: var(--accent-soft-2); }
.map-tile.on { border-color: var(--accent); background: var(--accent-soft); }
.map-tile.off { opacity: 0.55; }
.map-tile .mt-label { font-size: 12px; font-weight: 500; color: var(--ink-2); line-height: 17px; }
.map-tile .mt-value { font-size: 26px; font-weight: 600; letter-spacing: -0.6px; line-height: 34px; }
.map-tile .mt-foot { font-size: 11px; font-weight: 400; color: var(--muted); line-height: 15px; }
.map-tile .mt-dot { position: absolute; top: 15px; right: 14px; }
.mt-dot {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px;
  box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px rgba(27, 32, 40, 0.14);
}

.map-bar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.map-bar .map-bar-t { font-size: 12px; font-weight: 500; color: var(--muted); margin-right: 2px; }
.map-bar select {
  height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface);
  color: var(--ink); font: 500 12px/1.4 var(--font); padding: 0 8px; max-width: 220px;
}
.map-legend { margin-bottom: 12px; }
.leg[disabled] { cursor: default; }

/* кластер: кружок с числом вместо десятка слипшихся точек */
.map-cl-wrap { background: none; border: 0; }
.map-cl {
  width: 100%; height: 100%; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font: 600 12px/1 var(--font); font-variant-numeric: tabular-nums;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px rgba(27, 32, 40, 0.18);
}

.map-popup { min-width: 210px; }
.map-popup .popup-st { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; margin-bottom: 7px; }
.map-popup .popup-k { color: var(--muted); }
.map-popup .popup-r { margin-top: 2px; }
.map-popup .popup-r.muted { color: var(--muted); }

.map-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
table.tbl tr.picked td { background: var(--accent-soft); }

/* правка адреса прямо в списке: поле плюс кнопка */
table.tbl td.fix-td { white-space: nowrap; }
.fix-cell { display: flex; align-items: center; gap: 6px; }
.fix-in {
  height: 30px; width: 210px; padding: 0 9px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface); color: var(--ink); font: 500 12px/1.4 var(--font);
}
.fix-in:focus { outline: none; border-color: var(--accent); }
.fix-in[disabled] { opacity: 0.6; }
.fix-msg { font-size: 11px; font-weight: 500; color: var(--muted); min-width: 60px; }
.fix-msg.good { color: var(--good); }
.fix-msg.bad { color: var(--bad); }

/* таблица «Адрес не распознан»: колонок много, поэтому колонки уже и поля плотнее */
.tbl-tight table.tbl { font-size: 12px; }
.tbl-tight table.tbl th, .tbl-tight table.tbl td { padding: 0 7px; }
.tbl-tight table.tbl td.wrap { min-width: 96px; }
.tbl-tight .fix-in { width: 170px; }
.tbl-tight .fix-msg { min-width: 48px; }

@media (max-width: 1400px) {
  .map-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
  .map-cols { grid-template-columns: minmax(0, 1fr); }
}
