/* ============================================================
   Комплекс приёма и обработки обращений — стили админ-панели
   Government monochrome + blue accent
   ============================================================ */

:root {
  --bg: #f4f4f4;
  --card: #ffffff;
  --border: #d9d9d9;
  --ink: #111111;
  --ink-2: #555555;
  --ink-3: #888888;
  --line: #000000;
  --head: #e0e0e0;

  --accent: #0d5cb6;
  --accent-hover: #0a4a94;
  --accent-light: #e8f0fe;
  --accent-mid: #4a90d9;

  --ok: #1a7f37;
  --ok-bg: #e6f4ea;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --danger: #c0392b;
  --danger-bg: #fde8e8;

  --ch-1: #0d5cb6;
  --ch-2: #4a90d9;
  --ch-3: #8bb8e8;
  --ch-4: #b8d4f0;
  --ch-5: #d4e4f5;
  --ch-6: #e8f0fe;
  --ch-gray: #999999;

  --sidebar-w: 208px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 52px;
  --radius: 4px;
  --shadow-popup: 0 2px 8px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Клавиатурный фокус (WCAG 2.1 AA) ---------- */
.chip:focus-visible,
.kpi-card.clickable:focus-visible,
tr.row-click:focus-visible,
.bar-row:focus-visible,
.vbar-col:focus-visible,
.funnel-step:focus-visible,
.leg-item:focus-visible,
.xport-btn:focus-visible,
.pager-btn:focus-visible,
.month-btn:focus-visible,
.cal-day:focus-visible,
.quick-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #1a1a1a;
  color: #ccc;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: width 0.2s ease;
}

.sidebar-brand {
  padding: 12px 12px 12px;
  border-bottom: 1px solid #333;
  display: flex;
  flex-direction: column;
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-spacer { flex: 1; }
.brand-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e0e0e0;
  text-decoration: none;
  outline: none;
}
.brand-icon:hover { opacity: 0.85; }
.brand-icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.sidebar-brand .brand-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  text-decoration: none;
  margin-top: 8px;
}
.sidebar-brand .brand-title:hover { color: var(--accent-mid); }
.sidebar-brand .brand-sub {
  font-size: 0.72rem;
  color: #888;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}
.sidebar-section {
  padding: 8px 16px 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #777;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: #bbb;
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.sidebar-link:hover {
  background: #2a2a2a;
  color: #fff;
}
.sidebar-link.active {
  background: #2a2a2a;
  color: #fff;
  border-left-color: var(--accent);
}
.sidebar-link .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-link.active .nav-icon { opacity: 1; }
.sidebar-link .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 16px;
  font-size: 0.75rem;
  color: #666;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.sidebar-footer .user-name { color: #aaa; font-weight: 600; }
.sidebar-footer .user-role { color: #666; }
.sidebar-qr {
  display: block;
  width: 150px;
  height: 150px;
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid #555;
  transition: border-color 0.15s;
}
.sidebar-qr:hover { border-color: var(--accent-mid); }
.sidebar-qr canvas { display: block; width: 100%; height: 100%; }
.sidebar-demo-label {
  font-size: 0.65rem;
  color: #666;
  text-align: center;
  letter-spacing: 0.02em;
}
.sidebar-site-link {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent-mid);
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.15s;
}
.sidebar-site-link:hover { color: #fff; }
.sidebar-doc-wrap {
  padding: 0 12px 12px;
}
.sidebar-doc {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #3a3a3a;
  border-radius: var(--radius);
  color: #bbb;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.sidebar-doc:hover {
  background: #2a2a2a;
  color: #fff;
  border-color: var(--accent-mid);
}
.sidebar-doc svg { width: 15px; height: 15px; flex-shrink: 0; opacity: 0.8; }

/* ---------- Main area ---------- */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.2s ease;
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar-spacer { flex: 1; }
.topbar-month {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.month-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}
.month-btn:hover { background: var(--accent-light); border-color: var(--accent-mid); }
.month-btn.open { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.month-btn .month-ico { width: 16px; height: 16px; color: var(--ink-2); flex: none; }
.month-btn.open .month-ico { color: var(--accent); }
.month-btn .month-label { min-width: 0; }
.month-btn .month-chev { width: 14px; height: 14px; color: var(--ink-3); flex: none; transition: transform 0.15s ease; }
.month-btn.open .month-chev { transform: rotate(180deg); }

/* ---------- Period dropdown (calendar + quick ranges) ---------- */
.month-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 100;
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popup);
  overflow: hidden;
}
.month-dropdown[hidden] { display: none; }
.dd-col { padding: 14px; }
.dd-cal { width: 268px; border-right: 1px solid var(--border); }
.dd-quick { width: 200px; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 40px; height: 40px;
  cursor: pointer;
  color: var(--ink-2);
  font-size: 1rem; line-height: 1;
}
.cal-nav:hover { background: var(--accent-light); color: var(--accent); }
.cal-title { font-size: 0.85rem; font-weight: 600; color: var(--ink); }

.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.cal-week span { text-align: center; font-size: 0.7rem; color: var(--ink-3); font-weight: 600; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-day, .cal-blank {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.cal-day { background: none; border: none; cursor: pointer; color: var(--ink); }
.cal-day:hover { background: var(--accent-light); color: var(--accent); }
.cal-day.disabled { color: var(--ink-3); opacity: 0.4; cursor: not-allowed; }
.cal-day.in-month { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.cal-day.in-month:hover { background: var(--accent-mid); color: #fff; }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.in-range { background: var(--accent-light); color: var(--accent); }
.cal-day.range-start, .cal-day.range-end { background: var(--accent); color: #fff; font-weight: 600; }
.cal-day.range-start { border-radius: 6px 0 0 6px; }
.cal-day.range-end { border-radius: 0 6px 6px 0; }
.cal-day.range-start:hover, .cal-day.range-end:hover { background: var(--accent-hover); }

.cal-foot { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.cal-range-row { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--ink-2); margin-bottom: 4px; }
.cal-range-row strong { color: var(--ink); font-weight: 600; }
.cal-apply {
  width: 100%;
  margin-top: 8px;
  padding: 7px 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.cal-apply:hover:not(:disabled) { background: var(--accent-hover); }
.cal-apply:disabled { opacity: 0.4; cursor: not-allowed; }

.quick-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 8px;
}
.quick-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%;
  text-align: left;
  background: none; border: none; border-radius: 6px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--ink);
  font-size: 0.82rem; font-weight: 600;
  margin-bottom: 2px;
}
.quick-item small { font-size: 0.72rem; color: var(--ink-3); font-weight: 400; }
.quick-item:hover { background: var(--accent-light); color: var(--accent); }
.quick-item.active { background: var(--accent-light); color: var(--accent); }
.quick-item.disabled { opacity: 0.4; cursor: not-allowed; }
.quick-item.disabled:hover { background: none; color: var(--ink); }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.topbar-user .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
}

/* ---------- Content ---------- */
.content {
  flex: 1;
  padding: 20px;
}

/* ---------- Cards & Grids ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.card-title {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}
.card-title .hint {
  font-weight: 400;
  color: var(--ink-3);
  font-size: 0.8rem;
  margin-left: 8px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.grid-1-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 16px; }
.grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-2-1 > *, .grid-1-2 > * { min-width: 0; }

/* ---------- KPI Cards ---------- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: default;
}
.kpi-card.clickable { cursor: pointer; }
.kpi-card.clickable:hover { border-color: var(--accent); background: var(--accent-light); }
.kpi-label {
  font-size: 0.75rem;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.kpi-value.danger { color: var(--danger); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.ok { color: var(--ok); }
/* Акцентные KPI-карточки (эскалация, просрочка) */
.kpi-card.accent-warn {
  border-left: 3px solid var(--warn);
  background: linear-gradient(to right, var(--warn-bg) 0%, var(--card) 45%);
}
.kpi-card.accent-danger {
  border-left: 3px solid var(--danger);
  background: linear-gradient(to right, var(--danger-bg) 0%, var(--card) 45%);
}
.kpi-card.accent-warn.clickable:hover { border-color: var(--warn); border-left-color: var(--warn); }
.kpi-card.accent-danger.clickable:hover { border-color: var(--danger); border-left-color: var(--danger); }
.kpi-sub {
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- «Требуют внимания» ---------- */
.attention-list {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.attention-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink);
  transition: all 0.15s;
}
.attention-item:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}
.att-num {
  font-size: 1.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.att-num.warn { color: var(--warn); }
.att-num.danger { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; min-width: 0; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.data-table th {
  background: var(--head);
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
}
.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tr:hover td { background: #fafafa; }
.data-table tr.row-click { cursor: pointer; }
.data-table tr.row-click:hover td { background: var(--accent-light); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges & Tags ---------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: #eee; color: var(--ink-2); }

.pri-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.pri-dot.high { background: var(--danger); }
.pri-dot.mid { background: var(--warn); }
.pri-dot.low { background: var(--ch-gray); }

/* ---------- Filter chips ---------- */
.chip-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--card);
  color: var(--ink-2);
  transition: all 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.chip svg { flex-shrink: 0; margin-right: 5px; }
/* Иконка в KPI-метке */
.kpi-label svg { vertical-align: -2px; margin-right: 4px; }
/* Акцентные attention-элементы */
.attention-item.accent-warn { border-color: var(--warn); background: var(--warn-bg); }
.attention-item.accent-danger { border-color: var(--danger); background: var(--danger-bg); }

/* ---------- Charts (CSS-based) ---------- */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}
.bar-row .bar-label {
  width: 120px;
  flex-shrink: 0;
  text-align: right;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-row .bar-track {
  flex: 1;
  height: 20px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.bar-row .bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.3s;
}
.bar-row .bar-val {
  width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 0.78rem;
}

.vbar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding-top: 8px;
}
.vbar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
}
.vbar-col .vbar {
  width: 100%;
  max-width: 36px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.vbar-col .vbar-label {
  font-size: 0.65rem;
  color: var(--ink-3);
  text-align: center;
}
.vbar-col .vbar-val {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-2);
}
.vbar-col .vbar-delta {
  font-size: 0.6rem;
  font-weight: 700;
  line-height: 1.1;
}
.vbar-col .vbar-delta.up { color: var(--ok); }
.vbar-col .vbar-delta.down { color: var(--danger); }
/* Текущий месяц — выделение */
.vbar-col.current .vbar-label { font-weight: 700; color: var(--accent); }
.vbar-col.current .vbar-label::after {
  content: "";
  display: block;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--accent);
  margin: 1px auto 0;
}
/* Двухсерийная динамика: серии разнесены по строкам, стрелки — между барами своей серии */
.dual-trend { display: grid; gap: 14px; }
.dual-trend-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 8px;
}
.dual-row-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--ink-3);
}
.dual-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.dual-trend .vbar-chart { position: relative; height: 105px; }
.dual-trend .vbar-col .vbar { max-width: 30px; }
.dual-trend-row:first-child .vbar-label { visibility: hidden; }

.vbar-chart[data-arrows] { position: relative; }
.vbar-arrows {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
}
.trend-arrow { fill: none; stroke-width: 1.5; opacity: 0.9; }
.trend-arrow.up { stroke: var(--ok); }
.trend-arrow.down { stroke: var(--danger); }
.trend-arrow-marker.up { fill: var(--ok); }
.trend-arrow-marker.down { fill: var(--danger); }
.trend-arrow-label { font-size: 9px; font-weight: 700; text-anchor: middle; }
.trend-arrow-label.up { fill: var(--ok); }
.trend-arrow-label.down { fill: var(--danger); }

/* Donut */
.donut-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.donut {
  width: 140px;
  height: 140px;
  flex-shrink: 0;
}
.donut-svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.donut-visual { pointer-events: none; transition: opacity 0.12s; }
.donut-seg { pointer-events: all; transition: opacity 0.12s; }
.donut-svg text { pointer-events: none; }
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  flex: 1 1 160px;
  min-width: 0;
}
.donut-legend .leg-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.donut-legend .leg-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* Funnel */
.funnel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.funnel-step {
  height: 28px;
  background: var(--accent);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  transition: width 0.3s;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.funnel-step .funnel-val {
  margin-left: 8px;
  opacity: 0.85;
}

/* ---------- Placeholder page ---------- */
.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--ink-3);
  text-align: center;
  gap: 12px;
}
.placeholder .ph-icon {
  font-size: 3rem;
  opacity: 0.4;
}
.placeholder .ph-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink-2);
}
.placeholder .ph-text {
  font-size: 0.85rem;
  max-width: 360px;
}

/* ---------- Demo badge ---------- */
.demo-badge {
  position: fixed;
  bottom: 12px;
  right: 12px;
  background: var(--head);
  color: var(--ink-3);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 3px;
  z-index: 200;
}

/* ---------- Chart tooltip ---------- */
.chart-tooltip {
  position: fixed;
  pointer-events: none;
  background: #1a1a1a;
  color: #fff;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 4px;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: var(--shadow-popup);
  opacity: 0;
  transition: opacity 0.12s;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-label { color: #aaa; font-size: 0.7rem; }
.chart-tooltip .tt-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Chart interactivity ---------- */
.bar-row { transition: background 0.12s; border-radius: 3px; padding: 2px 4px; margin: 0 -4px; }
.bar-row:hover { background: var(--accent-light); }
.bar-row.active { background: var(--accent-light); }
.bar-row.active .bar-fill { outline: 2px solid var(--accent); outline-offset: -2px; }
.bar-row.clickable, .vbar-col.clickable, .funnel-step.clickable { cursor: pointer; }

.vbar-col { border-radius: 3px; padding: 2px; margin: 0 -2px; transition: background 0.12s; }
.vbar-col:hover { background: var(--accent-light); }
.vbar-col.active { background: var(--accent-light); }

.donut-legend .leg-item { cursor: pointer; padding: 2px 6px; border-radius: 3px; margin: 0 -6px; transition: background 0.12s; }
.donut-legend .leg-item:hover { background: var(--accent-light); }
.donut-legend .leg-item.active { background: var(--accent-light); }

.funnel-step { transition: filter 0.12s; }
.funnel-step:hover { filter: brightness(0.85); }
.funnel-step.active { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- Export: кнопка «Скачать данные» при наведении ---------- */
.xport-host { position: relative; }
.xport-btn {
  position: absolute;
  top: 10px; right: 10px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-3);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, color 0.15s, border-color 0.15s, background 0.15s;
  z-index: 6;
}
.xport-btn svg { width: 15px; height: 15px; }
.xport-host:hover .xport-btn,
.xport-host:focus-within .xport-btn,
.xport-btn.open {
  opacity: 1;
  pointer-events: auto;
}
.xport-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}
.xport-menu {
  position: absolute;
  top: 54px; right: 10px;
  min-width: 148px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-popup);
  padding: 4px;
  display: none;
  z-index: 60;
}
.xport-menu.show { display: block; }
.xport-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  border: none;
  background: none;
  border-radius: 3px;
  font-size: 0.8rem;
  color: var(--ink);
  cursor: pointer;
}
.xport-item:hover { background: var(--accent-light); color: var(--accent); }

/* ---------- Sidebar toggle ---------- */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
}
.sidebar-toggle:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent);
}
.sidebar-toggle svg { width: 18px; height: 18px; }
.sidebar .sidebar-toggle {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-color: #444;
  color: #888;
}
.sidebar .sidebar-toggle:hover {
  background: #2a2a2a;
  border-color: var(--accent-mid);
  color: #fff;
}
.sidebar .sidebar-toggle svg { width: 16px; height: 16px; }

/* ---------- Collapsed sidebar (desktop) ---------- */
@media (min-width: 769px) {
  html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
  html.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
  html.sidebar-collapsed .sidebar-brand .brand-title,
  html.sidebar-collapsed .sidebar-brand .brand-sub,
  html.sidebar-collapsed .sidebar-brand .brand-icon,
  html.sidebar-collapsed .sidebar-brand .brand-spacer,
  html.sidebar-collapsed .sidebar-section,
  html.sidebar-collapsed .sidebar-footer,
  html.sidebar-collapsed .sidebar-link > span:not(.nav-badge) {
    display: none;
  }
  html.sidebar-collapsed .sidebar-brand {
    padding: 12px 8px;
  }
  html.sidebar-collapsed .sidebar-brand .brand-row {
    justify-content: center;
    gap: 0;
  }
  html.sidebar-collapsed .sidebar-link {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
    position: relative;
  }
  html.sidebar-collapsed .sidebar-link .nav-icon { opacity: 0.85; }
  html.sidebar-collapsed .sidebar-doc > span { display: none; }
  html.sidebar-collapsed .sidebar-doc-wrap { padding: 0 8px 12px; }
  html.sidebar-collapsed .sidebar-doc { justify-content: center; padding: 8px 0; gap: 0; }
  html.sidebar-collapsed .nav-badge {
    position: absolute;
    top: 6px;
    right: 12px;
    width: 8px;
    height: 8px;
    padding: 0;
    border-radius: 50%;
    font-size: 0;
  }
}

/* ---------- Mobile toggle ---------- */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.mobile-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--ink);
  margin: 4px 0;
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }
  .sidebar-overlay.show { display: block; }
  .sidebar-link { min-height: 44px; }

  .main { margin-left: 0; }
  .sidebar-toggle { display: none; }
  .mobile-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
  }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 0.92rem; max-width: 45%; }
  .topbar-user span { display: none; }
  .topbar-month { gap: 4px; }
  .topbar-month button { min-width: 44px; min-height: 44px; padding: 0; }
  .topbar-month .month-label { min-width: 100px; font-size: 0.8rem; }
  .month-dropdown { top: calc(100% + 6px); }
  .dd-cal { width: 232px; padding: 10px; }
  .dd-quick { width: 168px; padding: 10px; }
  .content { padding: 12px; padding-bottom: 40px; }
  .card { padding: 12px; margin-bottom: 12px; }
  table.data-table { min-width: 640px; }
  .grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 {
    grid-template-columns: 1fr;
  }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .kpi-value { font-size: 1.35rem; }
  .chip { display: inline-flex; align-items: center; min-height: 40px; }
  .bar-row .bar-label { width: 72px; }
  .vbar-col .vbar-label { font-size: 0.6rem; }
  .funnel-step { font-size: 0.72rem; }
  .demo-badge { bottom: 8px; right: 8px; }
}

@media (max-width: 480px) {
  html { font-size: 13px; }
  .kpi-row { grid-template-columns: 1fr; }
  .topbar-title { max-width: 38%; }
  .topbar-user { display: none; }
  .topbar-month .month-label { min-width: 64px; font-size: 0.74rem; }
  .vbar-chart { height: 100px; }
  .funnel-val { display: none; }
  table.data-table { min-width: 600px; font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 8px; }
}

.table-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--ink-3);
}
.pager-info {
  font-variant-numeric: tabular-nums;
}
.pager-btn {
  min-width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink-2);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
}
.pager-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.pager-btn:disabled {
  opacity: 0.45;
  cursor: default;
}
