:root {
  --bg: #faf9f5;
  --card: #ffffff;
  --ink: #1f1e1b;
  --muted: #6f6a60;
  --line: #e6e2d8;
  --accent: #c96442;
  --accent-soft: #f6e8e2;
  --ok: #4c8a4c;
  --warn: #b98a1f;
  --bad: #b0432f;
  --radius: 12px;
  font-size: 15px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.hidden { display: none !important; }

.logo { font-weight: 700; font-size: 17px; letter-spacing: -0.2px; }
.logo span { color: var(--accent); font-weight: 600; }

/* ------- вход ------- */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 36px; width: 360px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 8px 30px rgba(31,30,27,.06);
}
.login-sub { margin: 0 0 6px; color: var(--muted); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 15px;
  background: var(--bg); color: var(--ink);
}
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-card label.login-remember {
  flex-direction: row; align-items: center; gap: 9px; color: var(--ink); cursor: pointer;
}
.login-card .login-remember input { width: auto; margin: 0; }

/* ------- каркас: сайдбар слева ------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sb-header { padding: 20px 18px 14px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.notification-bell {
  position: relative; width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
}
.notification-bell:hover, .notification-bell.has-unread { border-color: var(--accent); background: var(--accent-soft); }
.notification-bell-badge {
  position: absolute; top: -7px; right: -7px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: var(--bad); color: #fff; border: 2px solid var(--card);
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
.tabs { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; }
.tab {
  border: none; background: none; padding: 9px 12px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--muted); text-align: left; width: 100%;
}
.tab:hover { background: var(--bg); color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }
.plan-sidebar-group { width: 100%; min-width: 0; }
.plan-sidebar-tab { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-sidebar-tab::after {
  content: '⌄'; flex: 0 0 auto; font-size: 17px; font-weight: 500; line-height: 1;
  transform: translateY(-2px); transition: transform .16s ease;
}
.plan-sidebar-tab[aria-expanded='true']::after { transform: translateY(1px) rotate(180deg); }
.plan-sidebar-filters {
  display: grid; gap: 7px; margin: 5px 2px 8px; padding: 10px 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
}
.plan-sidebar-filters-title {
  color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .01em;
}
.plan-sidebar-filters > select {
  width: 100%; min-width: 0; height: 38px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  color: var(--ink); font: inherit; font-size: 13px;
}
.plan-sidebar-filters .multi-combo { display: block; width: 100%; min-width: 0; }
.plan-sidebar-filters .multi-combo-trigger {
  min-width: 0; min-height: 38px; padding: 8px 42px 8px 10px; font-size: 13px;
}
.plan-sidebar-filters .multi-combo-panel { width: 100%; min-width: 0; max-width: none; }
.plan-sidebar-filters .multi-combo-search { height: 38px; line-height: 36px; }
.plan-sidebar-filters .multi-combo-actions { gap: 7px; padding-inline: 9px; }
.plan-sidebar-filters .multi-combo-actions .btn-link { font-size: 12px; }
.plan-sidebar-filters .multi-combo-item { padding-inline: 10px; font-size: 12px; }
.plan-sidebar-reset { width: 100%; min-height: 36px; }
.sb-footer { padding: 14px 18px; border-top: 1px solid var(--line); }
.sb-user { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; margin-bottom: 10px; }
.sb-actions { display: flex; gap: 8px; }
.role-badge {
  background: var(--accent-soft); color: var(--accent);
  padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.main { flex: 1; min-width: 0; width: 100%; padding: 24px 28px 80px; }
.global-back-row {
  display: flex; align-items: center; gap: 10px; min-height: 34px; margin: 0 0 16px;
}
.global-back-button { white-space: nowrap; }
.global-back-destination { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .tabs { flex-direction: row; flex-wrap: wrap; }
  .tab { width: auto; }
  .plan-sidebar-group { width: min(100%, 420px); }
  .plan-sidebar-group .tab { width: 100%; }
  .global-back-destination { display: none; }
}

/* Горизонтальный скролл широких таблиц остаётся внутри карточки и не
   растягивает всю страницу. */
.table-scroll {
  min-width: 0; max-width: 100%; overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.pharmacy-address { display: block; min-width: 280px; max-width: 440px; white-space: normal; }

/* В таблице промокодов 11 столбцов. Не сжимаем два крайних столбца до
   нескольких пикселей: широкая таблица аккуратно прокручивается в карточке. */
.table-scroll.codes-table table { min-width: 1480px; table-layout: auto; }
.codes-table th, .codes-table td { overflow-wrap: normal; word-break: normal; }
.codes-table th:nth-child(1), .codes-table td:nth-child(1) { width: 44px; min-width: 44px; }
.codes-table th:nth-child(2), .codes-table td:nth-child(2) { min-width: 105px; }
.codes-table th:nth-child(3), .codes-table td:nth-child(3) { min-width: 112px; }
.codes-table th:nth-child(4), .codes-table td:nth-child(4) { min-width: 160px; }
.codes-table th:nth-child(5), .codes-table td:nth-child(5) { min-width: 110px; }
.codes-table th:nth-child(6), .codes-table td:nth-child(6) { min-width: 150px; }
.codes-table th:nth-child(7), .codes-table td:nth-child(7) { min-width: 180px; }
.codes-table th:nth-child(8), .codes-table td:nth-child(8) { min-width: 220px; }
.codes-table th:nth-child(9), .codes-table td:nth-child(9) { min-width: 92px; }
.codes-table th:nth-child(10), .codes-table td:nth-child(10) { min-width: 120px; }
.codes-table th:nth-child(11), .codes-table td:nth-child(11) { min-width: 150px; }
.codes-table td:last-child .btn-link { white-space: nowrap; }

/* ------- кнопки ------- */
.btn-primary {
  background: var(--ink); color: #fff; border: none; border-radius: 8px;
  padding: 10px 18px; font-size: 14px; cursor: pointer;
}
.btn-primary:hover { background: #35332e; }
.btn-accent {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; cursor: pointer;
}
.btn-ghost {
  background: none; border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; padding: 0; }

/* ------- карточки и сетки ------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.kpi .kpi-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.plan-filter-card { padding: 14px 16px; }
.plan-filters { display: grid; grid-template-columns: minmax(150px, .7fr) minmax(210px, 1fr)
  repeat(3, minmax(220px, 1.2fr)) auto; align-items: start; }
.plan-filters > select, .plan-filters > .filter-control, .plan-filters > button {
  width: 100%; min-width: 0;
}
.plan-trend-card { overflow: hidden; }
.plan-chart-legend { display: flex; gap: 20px; margin: 8px 0 14px; color: var(--muted); }
.plan-legend::before { content: ''; display: inline-block; width: 12px; height: 12px;
  margin-right: 7px; border-radius: 3px; vertical-align: -1px; }
.plan-legend.plan::before { background: #d7d2ca; }
.plan-legend.fact::before { background: var(--accent); }
.plan-chart { display: grid; grid-template-columns: repeat(12, minmax(54px, 1fr)); gap: 10px;
  min-width: 760px; height: 245px; padding: 10px 4px 0; overflow-x: auto; }
.plan-chart-column { display: grid; grid-template-rows: 1fr auto; min-height: 210px; }
.plan-chart-bars { display: flex; align-items: end; justify-content: center; gap: 5px;
  min-height: 180px; border-bottom: 1px solid var(--line); }
.plan-chart-bar { width: min(21px, 38%); min-height: 0; border-radius: 5px 5px 0 0;
  transition: height .2s ease; }
.plan-chart-bar.plan { background: #d7d2ca; }
.plan-chart-bar.fact { background: var(--accent); }
.plan-chart-bar.fact.overfulfilled { background: var(--ok); }
.plan-chart-bar.fact.estimate { background: repeating-linear-gradient(135deg,
  var(--accent), var(--accent) 5px, #e8c4b4 5px, #e8c4b4 9px); opacity: .85; }
.plan-chart-bar.fact.estimate.overfulfilled { background: repeating-linear-gradient(135deg,
  var(--ok), var(--ok) 5px, #bfdcc4 5px, #bfdcc4 9px); }
.plan-legend.estimate::before { background: repeating-linear-gradient(135deg,
  var(--accent), var(--accent) 4px, #e8c4b4 4px, #e8c4b4 7px); }
.plan-preliminary { white-space: nowrap; font-size: 12.5px; }
.kpi-preliminary { border-style: dashed; }
.plan-chart-month { padding-top: 8px; text-align: center; color: var(--muted);
  font-size: 12px; font-weight: 700; }
.plan-monthly-filters { margin: 14px 0 8px; }
.plan-monthly-filters > select,
.plan-monthly-filters > .filter-control { flex: 1 1 210px; min-width: 180px; }
.plan-monthly-filters > button { flex: 0 0 auto; }
.plan-monthly-count { margin: 0 0 12px; font-size: 13px; }
.plan-performance-table { overflow-x: hidden; }
.plan-performance-table table { width: 100%; min-width: 0; table-layout: fixed; }
.plan-performance-table th, .plan-performance-table td {
  padding: 7px 5px; overflow-wrap: anywhere; word-break: normal;
}
.plan-performance-table th {
  white-space: normal; line-height: 1.15; vertical-align: bottom;
}
.plan-performance-table .pill { padding: 2px 5px; white-space: nowrap; }
.plan-performance-table .plan-person-with-action { gap: 4px; }
.plan-performance-table .plan-person-drill { white-space: normal; }
.plan-performance-metric {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap;
}
.plan-performance-table th:nth-child(1) { width: 15%; }
.plan-performance-table th:nth-child(2) { width: 6%; }
.plan-performance-table th:nth-child(3) { width: 9%; }
.plan-performance-table th:nth-child(4) { width: 8%; }
.plan-performance-table th:nth-child(5),
.plan-performance-table th:nth-child(6) { width: 10%; }
.plan-performance-table th:nth-child(7),
.plan-performance-table th:nth-child(8) { width: 12%; }
.plan-performance-table th:nth-child(9) { width: 18%; }
.plan-monthly-table table { width: 100%; min-width: 0; table-layout: fixed; }
.plan-monthly-table th, .plan-monthly-table td {
  padding: 7px 4px; overflow-wrap: anywhere; word-break: normal;
}
.plan-monthly-table th {
  white-space: normal; line-height: 1.15; vertical-align: bottom;
}
.plan-monthly-table .pill { padding: 2px 5px; white-space: normal; }
.plan-monthly-table .plan-person-with-action { gap: 3px; }
.plan-monthly-table .plan-person-drill,
.plan-monthly-table .plan-pharmacy-toggle { white-space: normal; }
.plan-monthly-table th:nth-child(1) { width: 5%; }
.plan-monthly-table th:nth-child(2) { width: 6%; }
.plan-monthly-table th:nth-child(3) { width: 8%; }
.plan-monthly-table th:nth-child(4) { width: 12%; }
.plan-monthly-table th:nth-child(5) { width: 3%; }
.plan-monthly-table th:nth-child(6),
.plan-monthly-table th:nth-child(7),
.plan-monthly-table th:nth-child(8) { width: 5%; }
.plan-monthly-table th:nth-child(9),
.plan-monthly-table th:nth-child(10) { width: 6%; }
.plan-monthly-table th:nth-child(11),
.plan-monthly-table th:nth-child(13) { width: 7%; }
.plan-monthly-table th:nth-child(12),
.plan-monthly-table th:nth-child(14) { width: 5%; }
.plan-monthly-table th:nth-child(15) { width: 10%; }
.plan-ranking-table { overflow-x: hidden; }
.plan-ranking-table table { width: 100%; min-width: 0; table-layout: fixed; }
.plan-ranking-table th, .plan-ranking-table td {
  padding: 7px 3px; overflow-wrap: anywhere; word-break: normal;
}
.plan-ranking-table th {
  white-space: normal; line-height: 1.15; vertical-align: bottom;
}
.plan-ranking-table th:nth-child(1) { width: 3.5%; }
.plan-ranking-table th:nth-child(2) { width: 11%; }
.plan-ranking-table th:nth-child(3) { width: 5%; }
.plan-ranking-table th:nth-child(4),
.plan-ranking-table th:nth-child(5) { width: 8%; }
.plan-ranking-table th:nth-child(6),
.plan-ranking-table th:nth-child(7),
.plan-ranking-table th:nth-child(8),
.plan-ranking-table th:nth-child(9) { width: 7.5%; }
.plan-ranking-table th:nth-child(10) { width: 11.5%; }
.plan-ranking-table th:nth-child(11),
.plan-ranking-table th:nth-child(12),
.plan-ranking-table th:nth-child(13) { width: 5.5%; }
.plan-ranking-table th:nth-child(14) { width: 6.5%; }
.plan-ranking-table .pill { padding: 2px 5px; white-space: normal; }
.plan-ranking-table .plan-person-with-action { gap: 4px; }
.plan-ranking-table .plan-person-drill { white-space: normal; }
.plan-ranking-pending .muted,
.plan-ranking-pending .foreign-loyalty-trigger {
  white-space: normal; line-height: 1.25; overflow-wrap: anywhere;
}
.plan-ranking-dropdown { padding: 0; overflow: hidden; }
.plan-ranking-summary {
  position: relative; display: flex; align-items: center; gap: 16px;
  padding: 18px 52px 18px 20px; cursor: pointer; list-style: none; user-select: none;
}
.plan-ranking-summary::-webkit-details-marker { display: none; }
.plan-ranking-summary::after {
  content: '⌄'; position: absolute; right: 20px; top: 50%; color: var(--muted);
  font-size: 18px; line-height: 1; transform: translateY(-55%); transition: transform .18s ease;
}
.plan-ranking-dropdown[open] > .plan-ranking-summary {
  border-bottom: 1px solid var(--line);
}
.plan-ranking-dropdown[open] > .plan-ranking-summary::after {
  transform: translateY(-45%) rotate(180deg);
}
.plan-ranking-summary:hover .plan-ranking-summary-title,
.plan-ranking-summary:focus-visible .plan-ranking-summary-title { color: var(--accent); }
.plan-ranking-summary:focus-visible { outline: 3px solid #d9e7ff; outline-offset: -3px; }
.plan-ranking-summary-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.plan-ranking-summary-meta { margin-left: auto; font-size: 12px; text-align: right; }
.plan-ranking-body { padding: 18px 20px; }
.plan-ranking-body > .muted:first-child { margin-top: 0; }
.foreign-loyalty-trigger { font-weight: 700; text-decoration: underline dotted;
  text-underline-offset: 3px; white-space: nowrap; }
.kpi-value .foreign-loyalty-trigger { font-size: inherit; }
.plan-period-pharmacy-host:not(:empty) { margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--line); }
.plan-period-pharmacy-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.plan-period-pharmacy-controls select { min-width: 220px; }
.plan-period-pharmacy-detail:not(:empty) { margin-top: 12px; }
.plan-pharmacy-toggle { padding: 0; white-space: nowrap; }
.plan-person-with-action { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.plan-person-drill { padding: 0; color: var(--text); font-weight: 600; text-align: left;
  text-decoration: underline dotted; text-underline-offset: 3px; }
.plan-person-drill:hover { color: var(--accent); }
.plan-pharmacy-main-row.expanded > td { background: #faf8f4; border-bottom-color: transparent; }
.plan-pharmacy-detail-row[hidden] { display: none; }
.plan-pharmacy-detail-row > td { padding: 0 10px 14px; border-bottom: 1px solid var(--line);
  background: #faf8f4; }
.plan-pharmacy-detail { width: 100%; min-width: 0; box-sizing: border-box; overflow: hidden;
  border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 14px 16px; background: var(--card); }
.plan-pharmacy-head { display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 10px; }
.plan-pharmacy-head strong { display: block; margin-bottom: 3px; }
.plan-pharmacy-formula { font-size: 12px; }
.plan-pharmacy-summary { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0;
  font-size: 13px; }
.plan-pharmacy-fact { color: var(--ok); font-weight: 700; }
.plan-pharmacy-warning { margin-top: 10px; padding: 9px 11px; border: 1px solid #e6b7a8;
  border-radius: 8px; background: #fbebe6; color: var(--danger); font-size: 12px; line-height: 1.4; }
.plan-pharmacy-detail .table-scroll { margin-top: 10px; border: 1px solid var(--line);
  border-radius: 8px; }
.plan-pharmacy-table table { min-width: 1280px; }
.plan-pharmacy-table th, .plan-pharmacy-table td { padding-top: 9px; padding-bottom: 9px; }
.plan-pharmacy-status { display: flex; min-width: 180px; max-width: 220px;
  flex-direction: column; align-items: flex-start; gap: 5px; }
.plan-pharmacy-status small { white-space: normal; line-height: 1.3; }
.plan-pharmacy-discrepancies { margin-top: 14px; }
.plan-pharmacy-discrepancies h4 { margin: 0 0 9px; font-size: 13px; }
.plan-pharmacy-discrepancy { margin-top: 8px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; overflow: hidden; }
.plan-pharmacy-discrepancy > summary { padding: 10px 12px; cursor: pointer;
  color: var(--danger); font-size: 12px; font-weight: 700; }
.plan-pharmacy-discrepancy[open] > summary { border-bottom: 1px solid var(--line); }
.plan-pharmacy-discrepancy-address { padding: 9px 12px 0; font-size: 12px; }
.plan-pharmacy-discrepancy .table-scroll { margin: 8px 12px 12px; }
.plan-pharmacy-problem-table table { min-width: 760px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 14px; }
h2.section { font-size: 18px; margin: 0 0 16px; }
.trusted-devices-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px;
}
.trusted-devices-head h3 { margin-bottom: 5px; }
.trusted-devices-head p { margin: 0; }
.trusted-current { margin-left: 8px; white-space: nowrap; }
@media (max-width: 700px) {
  .trusted-devices-head { flex-direction: column; }
}

/* ------- таблицы ------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
     padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: none; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--bg); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.pill { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.pill.redeemed { background: #e5efe5; color: var(--ok); }
.pill.in_process { background: #f4ecd8; color: var(--warn); }
.pill.cancelled { background: #f5e1dc; color: var(--bad); }
.pill.loyalty { background: var(--accent-soft); color: var(--accent); }
.pill.sampling { background: #e4ebf3; color: #3d6a99; }
.pill.none { background: #eee; color: var(--muted); }
.pill.lekt { background: #e2ecf7; color: #3d6a99; }
.pill.konf { background: #f7e2ef; color: #a5487f; }
.btn-ghost.fm-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ------- фильтры ------- */
.filters {
  display: flex; gap: 10px 12px; flex-wrap: wrap; margin-bottom: 18px;
  align-items: center; min-width: 0;
}
.filters select, .filters > input, .filters .combo input,
.saved-filter-bar select {
  height: 42px; border: 1px solid var(--line); border-radius: 9px;
  padding: 0 13px; font: inherit; font-size: 14px; line-height: 40px;
  background: var(--card); color: var(--ink); transition: border-color .14s, box-shadow .14s;
}
.filters > select { min-width: 180px; max-width: 320px; }
.filters > input { min-width: 220px; flex: 1 1 230px; max-width: 390px; }
.filters > input[type="number"] { min-width: 120px; max-width: 180px; flex-basis: 140px; }
.filters select:focus, .filters input:focus, .saved-filter-bar select:focus {
  outline: none; border-color: #80aef8; box-shadow: 0 0 0 3px rgba(87, 143, 240, .32);
}
.filters input::placeholder, .combo input::placeholder { color: #aaa79f; opacity: 1; }
.filters > .btn-ghost { min-height: 42px; padding: 0 14px; white-space: nowrap; }
.filters > .muted { line-height: 42px; white-space: nowrap; }
.territory-match-pager { align-items: center; margin-top: 2px; }
.territory-match-pager .btn-ghost { min-width: 112px; }
.territory-match-filters { align-items: stretch; }
.territory-match-filters .combo { flex: 1 1 245px; max-width: 360px; }
.territory-match-filters > input { flex-basis: 190px; }
.territory-match-filters > select { flex: 0 1 230px; }
.territory-match-filters > input[type="number"] { flex-basis: 145px; }
.filters label {
  display: inline-flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: 13px; font-weight: 600;
}
.saved-filter-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 11px 14px; border: 1px solid var(--line);
  border-radius: 11px; background: color-mix(in srgb, var(--card) 90%, var(--bg));
}
.saved-filter-label { color: var(--muted); font-size: 13px; font-weight: 700; }
.saved-filter-bar select {
  min-width: 240px;
}
.saved-filter-bar .btn-ghost { min-height: 42px; }
.saved-filter-bar .btn-link { font-size: 13px; padding: 8px 2px; }
.saved-filter-message { flex: 1 1 240px; font-size: 11px; }
.bulk-toolbar {
  position: sticky; top: 8px; z-index: 8; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--ink);
  border-radius: 10px; background: var(--card); box-shadow: 0 7px 24px rgba(31,30,27,.12);
}
.bulk-toolbar strong { margin-right: 4px; }
.row-select { width: 16px; height: 16px; accent-color: var(--ink); cursor: pointer; }
.modal.bulk-operation-modal { width: min(620px, 92vw); }
.bulk-preview { margin: 14px 0; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.bulk-preview > div { margin-top: 6px; font-size: 12px; }
.bulk-warning { margin: 9px 0 0; color: var(--warn); font-size: 12px; line-height: 1.4; }
@media (max-width: 760px) {
  .saved-filter-bar select { min-width: 0; flex: 1 1 190px; }
  .saved-filter-message { flex-basis: 100%; }
}

/* Поисковый выпадающий фильтр (searchSelect) */
.combo { position: relative; display: inline-block; min-width: 220px; }
.combo input { width: 100%; min-width: 220px; padding-right: 32px; }
.combo-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); z-index: 2;
  border: none; background: none; color: var(--muted); font-size: 16px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.combo-clear:hover { color: var(--ink); }
.combo-list {
  position: absolute; top: calc(100% + 5px); left: 0; z-index: 50;
  width: max(100%, 280px); max-width: 390px; max-height: 330px; overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 32px rgba(31, 30, 27, .14); padding: 4px 0;
}
.combo-item {
  padding: 10px 14px; min-height: 40px; font-size: 14px; cursor: pointer; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.combo-item:hover, .combo-item.is-active { background: rgba(201, 100, 66, .08); }
.combo-item.is-selected { background: rgba(201, 100, 66, .12); }
/* В модалке label — flex-колонка: мобильный flex-basis комбо стал бы высотой. */
.modal .combo { flex: none; }
.combo-item.combo-all { color: var(--muted); border-bottom: 1px solid var(--line); }
.combo-empty { padding: 10px 14px; font-size: 14px; color: var(--muted); }

/* Поисковый фильтр с множественным выбором */
.multi-combo { position: relative; display: inline-block; min-width: 220px; }
.multi-combo-trigger {
  position: relative; width: 100%; min-width: 220px; min-height: 42px;
  padding: 10px 50px 10px 12px; overflow: hidden; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card); color: var(--ink); font: inherit;
  text-align: left; cursor: pointer;
}
.multi-combo-trigger::after {
  content: '⌄'; position: absolute; right: 15px; top: 50%; transform: translateY(-58%);
  color: var(--muted); font-size: 18px;
}
.multi-combo-trigger[aria-expanded='true'] { border-color: #7aa7f8; box-shadow: 0 0 0 3px #d9e7ff; }
.multi-combo-caption { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.multi-combo > .combo-clear { right: 34px; }
.multi-combo-panel {
  position: absolute; top: calc(100% + 5px); left: 0; z-index: 50;
  width: max(100%, 310px); max-width: 420px; background: var(--card);
  border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 32px rgba(31,30,27,.14); padding: 10px 0 4px;
}
.multi-combo-search {
  width: calc(100% - 20px); min-width: 0; height: 42px; margin: 0 10px 8px;
  border: 1px solid var(--line); border-radius: 9px; padding: 0 13px;
  background: var(--card); color: var(--ink); font: inherit; font-size: 14px;
  line-height: 40px; transition: border-color .14s, box-shadow .14s;
}
.multi-combo-actions {
  display: flex; justify-content: space-between; gap: 12px; padding: 2px 12px 8px;
  border-bottom: 1px solid var(--line);
}
.multi-combo-actions .btn-link { font-size: 14px; }
.multi-combo-list { max-height: 280px; overflow-y: auto; padding-top: 4px; }
.multi-combo-item {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 9px 14px;
  font-size: 14px; cursor: pointer;
}
.multi-combo-item:hover { background: rgba(201, 100, 66, .08); }
.multi-combo-item.is-selected { background: rgba(201, 100, 66, .12); }
.multi-combo-item input { width: 17px; height: 17px; flex: 0 0 auto; accent-color: var(--ink); }
.multi-combo-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Недельная динамика лояльности */
.week-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; margin: 12px 0 4px; }
.wk-col { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.wk-bar { width: 100%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; }
/* Текущая незавершённая неделя — как «прогнозный» столбик месяцев: светлая с пунктиром */
.wk-bar.wk-cur { background: var(--accent-soft); border: 1px dashed var(--accent); border-bottom: none; }
.wk-label { font-size: 9px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
/* «Ожидают выкупа» — светлая шапка над столбиком */
.wk-pend { width: 100%; max-width: 34px; background: var(--accent-soft); border: 1px dashed var(--accent); border-bottom: none; border-radius: 4px 4px 0 0; }
.wk-bar.wk-capped { border-radius: 0; }
/* Стыковая неделя: часть следующего месяца — светлее */
.wk-bar.wk-seg2 { background: #dd9a7c; }

/* Вложенные уровни раскрытия (ФМ → ТМ → МП) */
details.collapse details.collapse { margin-left: 16px; border-left: 2px solid var(--line); padding-left: 12px; }

/* Кнопочный фильтр по месяцам (пилюли) */
.month-bar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.month-bar .btn-ghost { border-radius: 20px; padding: 5px 14px; }
.month-bar .btn-ghost.month-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.month-bar .sampling-fm-filter { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.month-bar .sampling-fm-filter select { min-width: 220px; padding: 6px 32px 6px 10px; }

/* Карточки формы участия (Лекция / Конференция) */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; }
.form-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.form-card-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--muted); }
.form-card-value { margin-bottom: 14px; }
.form-card-value strong { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.form-card-unit { font-size: 14px; color: var(--muted); }
.form-card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; font-size: 13px; }
.mail-check { display: flex; align-items: center; gap: 9px; margin: 10px 0; }
.mail-check input { width: auto; margin: 0; }

/* ------- внутренний центр уведомлений ------- */
.modal.in-app-notifications-modal { width: min(700px, 92vw); }
.notification-center-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.notification-center-head h3 { margin-bottom: 4px; }
.notification-center-head p { margin: 0; font-size: 13px; }
.notification-center-filters { display: flex; gap: 7px; margin: 18px 0 12px; }
.notification-center-filters .month-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.notification-center-list { display: flex; flex-direction: column; gap: 8px; }
.notification-center-empty { padding: 34px 18px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 12px; }
.notification-item {
  width: 100%; display: flex; flex-direction: column; align-items: stretch; gap: 6px;
  text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px;
  color: var(--ink); background: var(--card); cursor: pointer; font: inherit;
}
.notification-item:hover { border-color: var(--accent); background: #fffdfb; }
.notification-item.is-unread { border-left: 4px solid var(--accent); background: #fffaf7; }
.notification-item.is-unread.severity-critical { border-left-color: var(--bad); background: #fff8f6; }
.notification-item-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.notification-type { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .25px; }
.notification-type.severity-info { color: #3d6a99; }
.notification-type.severity-success { color: var(--ok); }
.notification-type.severity-warning { color: var(--warn); }
.notification-type.severity-critical { color: var(--bad); }
.notification-item p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.notification-open { align-self: flex-end; color: var(--accent); font-size: 12px; font-weight: 600; }

/* Мини-графики по месяцам в KPI-карточках дашборда */
.mini-bars { display: flex; align-items: stretch; gap: 8px; height: 68px; margin-top: 10px; }
.mb-col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  justify-content: flex-end; text-align: center; cursor: default;
}
.mb-bar { background: var(--accent); border-radius: 3px 3px 0 0; margin: 0 auto; width: 100%; max-width: 42px; }
.mb-bar.mb-oper { background: #e8a98e; }
.mb-bar.mb-forecast { background: none; border: 1px dashed var(--accent); border-bottom: none; }
.mb-label { font-size: 11px; color: var(--muted); margin-top: 4px; white-space: nowrap; }
.mb-foot {
  font-size: 12px; margin-top: 10px; border-top: 1px solid var(--line);
  padding-top: 8px; display: flex; flex-direction: column; gap: 2px;
}
.mb-foot .muted { color: var(--muted); }

/* Помесячные темпы по территориальным менеджерам */
.team-trends { margin-top: 30px; }
.team-trends-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; margin-bottom: 14px;
}
.team-trends-head h2.section { margin-bottom: 5px; }
.team-trends-head p { margin: 0; max-width: 850px; font-size: 12px; line-height: 1.45; }
.team-trend-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.team-trend-key { white-space: nowrap; }
.team-trend-key::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 5px;
  border-radius: 2px; vertical-align: -1px; background: var(--accent);
}
.team-trend-key.operational::before {
  background: var(--accent-soft); border: 1px dashed var(--accent);
}
.team-trend-card { padding: 17px 20px 20px; }
.team-trend-card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding-bottom: 13px; margin-bottom: 12px; border-bottom: 1px solid var(--line);
}
.team-trend-name { font-size: 15px; font-weight: 700; text-align: left; }
.team-trend-grid { display: grid; grid-template-columns: repeat(3, minmax(220px, 1fr)); gap: 22px; }
.team-trend-grid.long-period { grid-template-columns: 1fr; gap: 10px; }
.team-trend-grid.long-period .team-trend-figure {
  display: grid; grid-template-columns: minmax(175px, 220px) minmax(0, 1fr);
  align-items: end; gap: 18px; padding: 8px 0 12px;
  border-bottom: 1px solid var(--line);
}
.team-trend-grid.long-period .team-trend-figure:last-child { border-bottom: none; padding-bottom: 2px; }
.team-trend-grid.long-period .team-trend-caption { align-self: start; margin: 3px 0 0; }
.team-trend-grid.long-period .team-trend-columns { min-width: 0; }
.team-trend-figure {
  --trend-color: var(--accent); --trend-soft: var(--accent-soft);
  min-width: 0; margin: 0; padding: 2px 0;
}
.team-trend-figure.loyalty { --trend-color: #3d6a99; --trend-soft: #e4ebf3; }
.team-trend-figure.sampling { --trend-color: #9b792c; --trend-soft: #f3ead5; }
.team-trend-caption {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  min-height: 38px; margin-bottom: 8px;
}
.team-trend-caption > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team-trend-caption strong { font-size: 12px; line-height: 1.25; }
.team-trend-caption .muted { font-size: 10px; }
.team-trend-total { font-variant-numeric: tabular-nums; color: var(--trend-color); }
.team-trend-columns { display: flex; align-items: stretch; gap: 5px; min-height: 122px; }
.team-trend-column {
  flex: 1 1 0; min-width: 0; display: grid; grid-template-rows: 18px 82px 17px;
  padding: 2px 3px 0; border-radius: 5px; cursor: default;
}
.team-trend-column.selected { background: #f2efe8; box-shadow: inset 0 0 0 1px #d8d2c4; }
.team-trend-value {
  align-self: start; text-align: center; font-size: 10px; line-height: 14px;
  font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap;
}
.team-trend-plot { position: relative; min-width: 0; }
.team-trend-plot::after {
  content: ''; position: absolute; z-index: 0; left: 0; right: 0;
  top: var(--trend-zero); border-top: 1px solid #d8d4ca;
}
.team-trend-bar {
  position: absolute; z-index: 1; left: 18%; width: 64%;
  background: var(--trend-color); border-radius: 3px 3px 0 0;
}
.team-trend-bar.negative { border-radius: 0 0 3px 3px; }
.team-trend-bar.operational {
  background: var(--trend-soft); border: 1px dashed var(--trend-color);
}
.team-trend-bar.zero { display: none; }
.team-trend-month {
  align-self: end; text-align: center; font-size: 9px; line-height: 14px;
  color: var(--muted); white-space: nowrap;
}

@media (max-width: 900px) {
  .team-trends-head { align-items: flex-start; flex-direction: column; }
  .team-trend-grid { grid-template-columns: 1fr; gap: 18px; }
  .team-trend-grid.long-period { gap: 18px; }
  .team-trend-grid.long-period .team-trend-figure {
    display: block; padding: 2px 0; border-bottom: none;
  }
  .team-trend-grid.long-period .team-trend-caption { margin-bottom: 8px; }
  .team-trend-grid.long-period .team-trend-columns {
    overflow-x: auto; padding-bottom: 5px; scrollbar-width: thin;
  }
  .team-trend-grid.long-period .team-trend-column { flex: 1 0 46px; }
  .team-trend-columns { min-height: 132px; }
  .team-trend-column { grid-template-rows: 20px 90px 17px; }
}

/* Мгновенные подсказки на графиках (системный title показывается с задержкой) */
.has-tip { position: relative; }
.has-tip:hover::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 5px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 11px; line-height: 1.3;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap;
  z-index: 60; pointer-events: none;
}

/* Возвращаемость: полосы состава месяцев */
.ret-cap { font-size: 11px; color: var(--muted); margin: 8px 0 3px; }
.ret-bar { display: flex; height: 16px; }
.ret-seg { min-width: 2px; }
.ret-seg:first-child { border-radius: 4px 0 0 4px; }
.ret-seg:last-child { border-radius: 0 4px 4px 0; }
.ret-seg.ret-back { background: var(--accent); }
.ret-seg.ret-new { background: var(--ok); }
.ret-seg.ret-wait { background: #f1efe8; border: 1px dashed #c9c5b8; }
.ret-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 8px; }
.ret-key::before {
  content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 4px; vertical-align: -1px; background: var(--accent);
}
.ret-key.ret-new::before { background: var(--ok); }
.ret-key.ret-wait::before { background: #f1efe8; border: 1px solid #c9c5b8; }

/* Сворачиваемые секции (details/summary) */
.collapse { margin: 18px 0; }
.collapse > summary {
  cursor: pointer; font-size: 17px; font-weight: 700; color: var(--ink);
  padding: 10px 0; list-style: none; user-select: none;
}
.collapse > summary::before { content: '▸ '; color: var(--accent); }
.collapse[open] > summary::before { content: '▾ '; }
.collapse > summary::-webkit-details-marker { display: none; }
.collapse > summary:hover { color: var(--accent); }

.territory-dispute-item {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  margin: 0 0 14px; background: color-mix(in srgb, var(--card) 94%, var(--bg));
  overflow-x: auto;
}
.territory-dispute-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 8px;
}
.territory-final-address { margin: 6px 0; font-weight: 600; }
.territory-dispute-item table { min-width: 880px; margin-top: 10px; }
.territory-dispute-item th:first-child,
.territory-dispute-item td:first-child { min-width: 260px; }
.territory-dispute-item th:nth-child(3),
.territory-dispute-item td:nth-child(3) { min-width: 230px; }
.territory-dispute-actions { display: flex; justify-content: flex-end; margin-top: 12px; }
.territory-candidate-actions {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; min-width: 150px;
}
.territory-candidate-actions .btn-link { padding: 4px 6px; }
.territory-excluded-candidates { margin-top: 12px; }
.territory-excluded-candidates > summary {
  cursor: pointer; color: var(--muted); font-weight: 600;
}
.territory-dispute-batch {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin: 12px 0 16px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--soft);
}
.territory-dispute-batch.has-pending {
  border-color: #e6b7a8; background: #fff7f3;
}
.territory-dispute-batch.has-pending p { color: var(--bad); }
.territory-dispute-batch p { margin: 0; }
.territory-operational-candidates {
  margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--card);
}
.territory-operational-candidates > summary {
  cursor: pointer; color: var(--accent); font-weight: 700; list-style: none;
}
.territory-operational-candidates > summary::-webkit-details-marker { display: none; }
.territory-operational-candidates > summary::before { content: '▸ '; }
.territory-operational-candidates[open] > summary::before { content: '▾ '; }
.territory-operational-search { margin: 12px 0; }
.territory-operational-search input { flex: 1 1 320px; }
.territory-operational-candidate-list { display: grid; gap: 8px; }
.territory-operational-candidate {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--soft);
}
.territory-operational-candidate p { margin-top: 4px; }
.territory-operational-candidate .btn-primary { flex: 0 0 auto; }
.territory-operational-target {
  margin-top: 10px; padding: 10px 12px; border-radius: 9px;
  color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--card));
  font-weight: 650;
}
.territory-operational-actions { align-items: center; gap: 12px; }
@media (max-width: 700px) {
  .territory-dispute-heading { align-items: flex-start; flex-direction: column; }
  .territory-dispute-item { padding: 12px; }
  .territory-operational-candidate { align-items: stretch; flex-direction: column; }
  .territory-operational-actions { align-items: stretch; flex-direction: column; }
}

/* ------- график ------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; }
.chart .bar { border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .bar.redeemed { background: var(--accent); }
.chart .bar.in_process { background: #d9c48a; }
.chart .bar.cancelled { background: #d8a396; }
.chart .month-label { font-size: 11px; color: var(--muted); text-align: center; margin-top: 6px; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* ------- проверки заливки ------- */
.check { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; font-size: 13px;
         border-bottom: 1px dashed var(--line); }
.check:last-child { border-bottom: none; }
.check .ok { color: var(--ok); font-weight: 700; }
.check .fail { color: var(--bad); font-weight: 700; }

/* ------- модалка ------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(31,30,27,.4);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  overflow: hidden; overscroll-behavior: contain;
}
.modal {
  background: var(--card); border-radius: 16px; padding: 26px; width: 420px; max-width: 92vw;
  max-height: 85vh; overflow: auto; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal-open { overflow: hidden; }
.modal.foreign-loyalty-modal {
  box-sizing: border-box; width: min(1180px, 94vw); max-width: 94vw;
}
.foreign-loyalty-modal .table-scroll table { min-width: 980px; }
.modal.operational-sampling-modal {
  box-sizing: border-box; width: min(1380px, 96vw); max-width: 96vw;
  max-height: 90vh;
}
.operational-sampling-modal .table-scroll {
  max-height: 58vh; overflow: auto;
}
.operational-sampling-modal .table-scroll table {
  min-width: 1050px; table-layout: auto;
}
.operational-sampling-modal th:nth-child(5),
.operational-sampling-modal td:nth-child(5) { min-width: 180px; }
.operational-sampling-modal th:nth-child(6),
.operational-sampling-modal td:nth-child(6) { min-width: 260px; }
.modal.territory-final-unmatched-modal {
  box-sizing: border-box; width: min(1500px, 96vw); max-width: 96vw;
}
.modal.territory-unassigned-resolution-modal {
  box-sizing: border-box; width: min(760px, 94vw); max-width: 94vw;
}
.territory-final-unmatched-modal .table-scroll table { min-width: 1420px; }
.territory-final-unmatched-filters { margin-bottom: 8px; }
.territory-final-unmatched-filters .combo { flex: 1 1 280px; max-width: 390px; }
.territory-final-unmatched-pager { position: sticky; bottom: -26px; padding: 12px 0 2px;
  background: var(--card); }
.territory-final-unmatched-link { appearance: none; border: 0; padding: 0; background: none;
  color: var(--accent); font: inherit; text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 3px; }
.territory-final-unmatched-link:hover { color: var(--bad); }
.territory-control-heading { margin: 24px 0 12px; }
.territory-menu-stack { display: grid; gap: 10px; margin: 0 0 8px; }
.territory-menu-field {
  margin: 0; padding: 0; border: 1px solid var(--line);
  border-radius: 12px; background: color-mix(in srgb, var(--card) 96%, var(--bg));
  overflow: hidden;
}
.territory-menu-field.is-attention {
  border-color: rgba(201,100,66,.32); background: rgba(201,100,66,.06);
}
.territory-menu-field.is-ok {
  border-color: color-mix(in srgb, var(--ok) 28%, var(--line));
  background: color-mix(in srgb, var(--ok) 5%, var(--card));
}
.territory-menu-field-summary {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; padding: 16px 48px 16px 18px; list-style: none; cursor: pointer;
}
.territory-menu-field.is-static .territory-menu-field-summary {
  padding-right: 18px; cursor: default;
}
.territory-menu-field-summary::-webkit-details-marker { display: none; }
.territory-menu-field:not(.is-static) > .territory-menu-field-summary::after {
  content: '⌄'; position: absolute; right: 18px; top: 50%;
  color: var(--accent); font-size: 22px; transform: translateY(-58%);
  transition: transform .16s ease;
}
.territory-menu-field[open] > .territory-menu-field-summary::after {
  transform: translateY(-42%) rotate(180deg);
}
.territory-menu-field[open] > .territory-menu-field-summary {
  border-bottom: 1px solid var(--line);
}
.territory-menu-field h4 { margin: 0 0 5px; font-size: 15px; }
.territory-menu-field p { margin: 0; }
.territory-menu-field-content > p + p { margin-top: 10px; }
.territory-menu-field-value { flex: 0 0 auto; text-align: right; }
.territory-menu-field-metrics { color: var(--accent); font-weight: 700; }
.territory-menu-field.is-ok .territory-menu-field-metrics { color: var(--ok); }
.territory-menu-field.is-attention .territory-menu-field-metrics { color: var(--bad); }
.territory-menu-field-content { padding: 16px 18px 18px; background: var(--card); }
.territory-standalone-heading { margin-top: 20px !important; }
.territory-standalone-filters > input { flex: 2 1 280px; }
.modal.territory-standalone-lines-modal {
  box-sizing: border-box; width: min(1380px, 96vw); max-width: 96vw;
}
.territory-standalone-lines-modal .table-scroll table { min-width: 1120px; }
.territory-final-unmatched-inline > p:first-child { margin-top: 0; }
.territory-final-unmatched-inline .table-scroll { max-width: 100%; }
.territory-final-unmatched-inline .table-scroll table { min-width: 1420px; }
.territory-final-unmatched-inline .territory-final-unmatched-pager {
  position: static; padding: 10px 0 0; background: transparent;
}
.modal h3 { margin: 0 0 16px; }
.modal label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal input, .modal select {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 14px;
}
.modal .modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.error { color: var(--bad); font-size: 13px; }
.success { color: var(--ok); font-size: 13px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.pagination { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }

.upload-zone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 30px;
  text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 5px; align-items: center;
}
.upload-zone:hover, .upload-zone.drag { box-shadow: 0 4px 14px rgba(31,30,27,.08); }
.upload-zone .uz-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.upload-zone .uz-sub { font-size: 12px; }
/* Каждая зона — свой цвет, чтобы файлы не путались */
.uz-weekly { border-color: #d9a173; background: #fdf4ea; }
.uz-weekly:hover, .uz-weekly.drag { border-color: var(--accent); }
.uz-bindings { border-color: #93b6d6; background: #eef4fa; }
.uz-bindings:hover, .uz-bindings.drag { border-color: #3d6a99; }
.uz-monthly { border-color: #9dc09d; background: #eff6ef; }
.uz-monthly:hover, .uz-monthly.drag { border-color: var(--ok); }
.uz-territory { border-color: #9ab8aa; background: #eef6f2; }
.uz-territory:hover, .uz-territory.drag { border-color: #40765e; }

.health { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

/* ------- предпросмотр перед публикацией заливки ------- */
.publication-card { border: 2px solid #e8d39a; background: #fffdf7; }
.publication-card > h3 { margin: 0 0 5px; }
.publication-review { margin-top: 14px; }
.publication-metrics {
  display: grid; grid-template-columns: repeat(5, minmax(125px, 1fr)); gap: 9px;
  margin: 12px 0;
}
.publication-metric {
  display: flex; flex-direction: column; gap: 3px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.publication-metric strong { font-size: 20px; }
.publication-metric small { font-size: 11px; }
.publication-metric.changed { border-color: #d9a173; background: #fdf4ea; }
.publication-metric.warning { border-color: #e1b86d; background: #fff8e6; }
.publication-unknown p { margin: 7px 0; }
.publication-anomalies {
  margin-top: 13px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  padding: 11px 0;
}
.publication-anomalies summary { cursor: pointer; font-weight: 700; }
.publication-anomalies h4 { margin: 16px 0 8px; }
.publication-anomalies .table-wrap { margin-bottom: 12px; }
.publication-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.btn-ghost.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }

@media (max-width: 900px) {
  .publication-metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

/* ------- управление справочниками ------- */
.ref-rebuild {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; margin-bottom: 18px; border: 1px solid #e8d39a;
  background: #fff8e6; border-radius: var(--radius); font-size: 13px;
}
.ref-rebuild.pending { border-color: var(--warn); background: #fff3d3; }
.ref-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 22px; }
.ref-tab {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 20px; padding: 7px 13px; font-size: 13px; cursor: pointer;
}
.ref-tab:hover { border-color: var(--ink); color: var(--ink); }
.ref-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.ref-section-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  margin-bottom: 14px;
}
.ref-section-head h2 { margin-bottom: 5px; }
.ref-section-head p { font-size: 12px; margin: 0; }
.ref-actions { display: flex; gap: 10px; white-space: nowrap; }
.btn-link.danger { color: var(--bad); }
.ref-search {
  width: min(420px, 100%); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 14px; margin-bottom: 14px;
}
.modal label.ref-check { flex-direction: row; align-items: center; gap: 8px; }
.modal label.ref-check input { width: auto; }
.modal textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; resize: vertical;
}
@media (max-width: 700px) {
  .ref-rebuild, .ref-section-head { align-items: stretch; flex-direction: column; }
}

/* ------- единая карточка участника ------- */
.doctor-name-link { text-align: left; font-weight: 650; }
.participant-packs { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 120px; }
.participant-packs-total { font-size: 15px; }
.participant-packs-months {
  max-width: 230px; color: var(--muted); font-size: 11px; line-height: 1.35;
  white-space: normal; text-align: right;
}
.doctor-card-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 20px;
  margin: 18px 0 20px;
}
.doctor-meta, .doctor-head-actions, .doctor-section-head, .doctor-doc-upload {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
}
.doctor-head-actions { justify-content: flex-end; }
.doctor-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.doctor-section { margin-bottom: 18px; overflow-x: auto; }
.doctor-section > h2, .doctor-section-head h2 { margin: 0 0 14px; font-size: 17px; }
.doctor-section-head { justify-content: space-between; margin-bottom: 14px; }
.doctor-section-head h2 { margin-bottom: 0; }
.doctor-master-comment { border-left: 4px solid var(--accent); margin-bottom: 18px; }
.doctor-master-comment p { white-space: pre-wrap; margin-bottom: 0; }
.doctor-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.doctor-owner-select { max-width: 220px; border: 1px solid var(--line); border-radius: 7px; padding: 6px; }
.doctor-message { display: block; max-width: 380px; white-space: pre-wrap; }
.doctor-note-form { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 16px; }
.doctor-note-form textarea {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font: inherit; resize: vertical;
}
.doctor-timeline { display: flex; flex-direction: column; gap: 10px; }
.doctor-timeline-item, .doctor-document {
  border-top: 1px solid var(--line); padding-top: 10px;
}
.doctor-timeline-item p { white-space: pre-wrap; margin: 6px 0; }
.doctor-document { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.doctor-document a { color: var(--ink); font-weight: 650; }
.doctor-doc-upload { margin-bottom: 16px; }
.doctor-doc-upload input { max-width: 240px; }
.doctor-audit-value { display: block; max-width: 460px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-card { overflow: hidden; }
.audit-table table { min-width: 1120px; table-layout: auto; }
.audit-value {
  display: block; max-width: 360px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.review-section { overflow: visible; }
.review-item { border: 1px solid var(--line); border-left-width: 5px; border-radius: 10px; padding: 14px 16px; margin-top: 12px; }
.review-item-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.review-item-head > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.risk-border-green { border-left-color: var(--ok); }
.risk-border-yellow { border-left-color: var(--warn); }
.risk-border-red { border-left-color: var(--bad); }
.review-badge, .review-status, .review-answer { display: inline-block; border-radius: 20px; padding: 3px 9px; font-size: 12px; font-weight: 650; }
.review-badge.risk-green { background: #e5efe5; color: var(--ok); }
.review-badge.risk-yellow { background: #f4ecd8; color: var(--warn); }
.review-badge.risk-red { background: #f5e1dc; color: var(--bad); }
.review-badge.risk-none { background: #eee; color: var(--muted); }
.review-status { background: var(--bg); color: var(--muted); }
.review-status.status-requires_action { background: #fff3d3; color: var(--warn); }
.review-status.status-resolved { background: #e5efe5; color: var(--ok); }
.review-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.review-checks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.review-answer { background: var(--bg); color: var(--muted); font-weight: 500; }
.review-answer.answer-yes { background: #edf5ed; color: var(--ok); }
.review-answer.answer-no { background: #fae9e5; color: var(--bad); }
.review-comment { white-space: pre-wrap; margin: 12px 0 0; }
.review-required, .review-resolution { border-radius: 8px; padding: 10px 12px; margin: 12px 0; font-size: 13px; }
.review-required { background: #fff8e6; border: 1px solid #e8d39a; }
.review-required p { white-space: pre-wrap; margin: 6px 0 0; }
.review-resolution { background: #edf5ed; color: var(--ok); }
@media (max-width: 980px) {
  .doctor-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doctor-two-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .doctor-card-head { flex-direction: column; }
  .doctor-head-actions { justify-content: flex-start; }
  .doctor-kpis { grid-template-columns: 1fr; }
  .doctor-note-form { align-items: stretch; flex-direction: column; }
}

/* ------- здоровье данных ------- */
.health-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: -8px 0 22px;
}
.health-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 24px;
}
.health-issue {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; min-height: 178px; display: flex; flex-direction: column;
}
.health-issue.has-issues { border-top: 3px solid var(--bad); }
.health-issue.is-clean { border-top: 3px solid var(--ok); }
.health-issue-title { font-size: 13px; font-weight: 700; min-height: 34px; }
.health-count { font-size: 30px; font-weight: 750; letter-spacing: -0.6px; margin-top: 6px; }
.health-issue.has-issues .health-count { color: var(--bad); }
.health-issue.is-clean .health-count { color: var(--ok); }
.health-unit { font-size: 11px; }
.health-desc { color: var(--muted); font-size: 12px; line-height: 1.4; flex: 1; margin: 9px 0; }
.health-detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.health-detail-head h2 { margin-bottom: 10px; }
.quality-task-cell { min-width: 118px; }
.health-trend-note { font-size: 12px; margin: -8px 0 12px; }
.health-trend { display: flex; flex-direction: column; gap: 10px; }
.health-trend-row {
  display: grid; grid-template-columns: minmax(125px, 180px) minmax(160px, 1fr) 58px minmax(170px, auto);
  align-items: center; gap: 10px; padding: 5px 7px; border-radius: 7px;
}
.health-trend-row.active { background: var(--accent-soft); }
.health-trend-label { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health-trend-track { height: 8px; background: var(--line); border-radius: 10px; overflow: hidden; }
.health-trend-bar { height: 100%; border-radius: inherit; }
.health-trend-bar.good { background: var(--ok); }
.health-trend-bar.warn { background: var(--warn); }
.health-trend-bar.bad { background: var(--bad); }
.health-trend-value { font-size: 12px; text-align: right; }
.health-trend-row > .muted { font-size: 11px; }
@media (max-width: 760px) {
  .health-trend-row { grid-template-columns: 115px 1fr 52px; }
  .health-trend-row > .muted { grid-column: 1 / -1; }
}

/* ------- задачи качества данных ------- */
.quality-task-filters { margin-bottom: 16px; }
.quality-task-tools { display: flex; justify-content: flex-end; gap: 8px; margin: -8px 0 12px; }
.quality-mine { display: flex; flex-direction: row; align-items: center; gap: 7px; font-size: 13px; }
.quality-mine input { width: auto; }
.quality-task-summary {
  display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px;
}
.pill.quality-new { background: #f4ecd8; color: #8a6416; }
.pill.quality-in_progress { background: #e4ebf3; color: #3d6a99; }
.pill.quality-review { background: #efe7f5; color: #7a4e9e; }
.pill.quality-fixed { background: #e5efe5; color: var(--ok); }
.pill.quality-reopened { background: #f5e1dc; color: var(--bad); }
.quality-priority { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; }
.priority-low { color: var(--muted); }
.priority-normal { color: #3d6a99; }
.priority-high { color: #a66b0f; }
.priority-critical { color: var(--bad); }
.modal.quality-task-modal { width: min(780px, 92vw); }
.quality-task-dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.quality-task-dialog-head h3 { margin-bottom: 5px; }
.quality-task-badges { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.quality-task-source { margin: 6px 0 10px; color: var(--muted); font-size: 12px; }
.quality-source {
  display: inline-flex; padding: 3px 7px; border-radius: 10px; font-size: 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .3px; white-space: nowrap;
}
.quality-source-health { color: #6d5930; background: #f4ecd8; }
.quality-source-alert { color: #9a3f2b; background: #f5e1dc; }
.quality-source-manual { color: #3d6a99; background: #e4ebf3; }
.quality-task-modal h4 { margin: 20px 0 9px; }
.quality-task-edit { margin: 16px 0; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.quality-task-edit summary { cursor: pointer; font-weight: 700; margin-bottom: 10px; }
.quality-task-workflow { display: flex; justify-content: flex-end; gap: 9px; margin: 16px 0; }
.quality-task-history { display: flex; flex-direction: column; gap: 9px; }
.quality-task-event {
  display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 3px 12px;
  border-left: 3px solid var(--line); padding: 7px 10px; font-size: 12px;
}
.quality-task-event p { grid-column: 1 / -1; margin: 3px 0 0; white-space: pre-wrap; }
.quality-task-event > span:last-of-type:not(:nth-child(2)) { grid-column: 1 / -1; }
.alert-settings-global {
  display: grid; grid-template-columns: minmax(240px, 1fr) 180px; gap: 16px;
  align-items: end; margin: 14px 0; padding: 13px; border: 1px solid var(--line); border-radius: 10px;
}
.modal label.alert-rule-toggle { flex-direction: row; align-items: center; gap: 8px; margin: 0; color: var(--ink); }
.modal label.alert-rule-toggle input { width: auto; }
.alert-rules-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.alert-rule-row {
  display: grid; grid-template-columns: minmax(300px, 1fr) auto; gap: 18px;
  align-items: center; padding: 13px 2px; border-bottom: 1px solid var(--line);
}
.alert-rule-text p { margin: 5px 0; font-size: 12px; }
.alert-rule-stats { font-size: 11px; color: var(--muted); }
.alert-rule-thresholds { display: flex; gap: 8px; align-items: end; }
.modal .alert-rule-thresholds label { width: 105px; margin: 0; }
.alert-rule-thresholds small { font-size: 10px; }
.alert-settings-message { min-height: 18px; margin-top: 12px; }
@media (max-width: 900px) {
  .quality-task-summary { grid-template-columns: repeat(2, minmax(130px, 1fr)); }
  .alert-rule-row { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .quality-task-dialog-head { flex-direction: column; }
  .quality-task-badges { justify-content: flex-start; }
  .quality-task-event { grid-template-columns: 1fr; }
  .alert-settings-global { grid-template-columns: 1fr; }
  .alert-rule-thresholds { flex-wrap: wrap; }
  .notification-center-head { flex-direction: column; }
  .notification-item-meta { align-items: flex-start; flex-direction: column; gap: 3px; }
}

/* ------- дельты KPI ------- */
.kpi-delta { font-size: 12px; font-weight: 600; margin-top: 4px; color: var(--muted); }
.kpi-delta.up { color: var(--ok); }
.kpi-delta.down { color: var(--bad); }

/* ------- шапка главной и приветствие ------- */
.page-head { margin-bottom: 16px; }
.dashboard-report-actions {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 12px;
}
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin: 0 0 4px; }
.page-sub { font-size: 13px; margin: 0; }
.greeting {
  background: #fdf3e3; border: 1px solid #f0dfc0; border-radius: var(--radius);
  padding: 13px 18px; font-size: 14px; margin-bottom: 22px;
}
.greeting strong { color: var(--accent); }

/* ------- how-to блок ------- */
.howto {
  background: var(--accent-soft); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.howto-title { font-weight: 700; font-size: 13px; margin-bottom: 10px; }
.howto-steps { display: flex; gap: 18px; flex-wrap: wrap; }
.howto-step { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; max-width: 300px; }
.howto-num {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.modal textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
  font-size: 14px; font-family: inherit; width: 100%;
}

/* ------- мобильная адаптация (в конце файла, чтобы перебивать базовые правила) ------- */
@media (max-width: 800px) {
  .main { padding: 16px 12px 60px; }
  .page-title, h1.page-title { font-size: 20px; }
  .kpi .kpi-value { font-size: 22px; }
  .kpi-row { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .card { padding: 14px 12px; }
  th, td { padding: 7px 8px; }
  /* Фильтры — крупнее и на всю ширину, удобные для пальца */
  .filters > select, .filters > input, .filters .combo {
    flex: 1 1 180px; min-width: 0; max-width: none;
  }
  .filters select, .filters > input, .filters .combo input { min-width: 0; font-size: 14px; }
  .combo { flex: 1 1 180px; display: block; }
  .combo input { width: 100%; min-width: 0; }
  .modal { width: calc(100vw - 24px); max-width: 420px; }
  .modal.operational-sampling-modal {
    width: calc(100vw - 24px); max-width: none;
  }
  .upload-zone { padding: 18px 12px; }
  /* На телефоне таблицам задаётся минимальная ширина — вместо каши
     из сжатых колонок они листаются вбок пальцем. */
  .table-scroll table { min-width: 560px; }
  .plan-filters { grid-template-columns: 1fr; }
  .plan-chart { min-width: 680px; }
  .plan-performance-table { overflow-x: auto; }
  .plan-performance-table table { min-width: 980px; }
  .plan-monthly-table table { min-width: 1100px; }
  .plan-ranking-table { overflow-x: auto; }
  .plan-ranking-table table { min-width: 1120px; }
  .plan-ranking-summary { align-items: flex-start; flex-direction: column; gap: 5px; }
  .plan-ranking-summary-meta { margin-left: 0; text-align: left; }
  .plan-ranking-body { padding: 14px 12px; }
  .territory-menu-field-summary {
    align-items: flex-start; flex-direction: column; gap: 10px; padding-right: 42px;
  }
  .territory-menu-field-value { text-align: left; }
  .territory-dispute-batch { align-items: stretch; flex-direction: column; }
}

/* Статусы корректирующих действий */
.pill.task-assigned { background: #f4ecd8; color: var(--warn); }
.pill.task-in_progress { background: #e4ebf3; color: #3d6a99; }
.pill.task-submitted { background: #efe7f5; color: #7a4e9e; }
.pill.task-returned { background: #f5e1dc; color: var(--bad); }
.pill.task-confirmed { background: #e5efe5; color: var(--ok); }
.pill.task-cancelled { background: #ecebe7; color: var(--muted); }
.pill.risk-red { background: #f5e1dc; color: var(--bad); }
.pill.risk-yellow { background: #f4ecd8; color: var(--warn); }
.pill.risk-green { background: #e5efe5; color: var(--ok); }
/* Счётчик у пункта навигации */
.tab-badge { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  background: var(--accent); color: #fff; border-radius: 10px; font-size: 11px; text-align: center; line-height: 18px; }

.quality-task-resolution {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin: 14px 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--accent-soft);
}
.quality-task-resolution p { margin: 5px 0 0; }
.quality-task-resolution .btn-primary { flex: 0 0 auto; }
@media (max-width: 700px) {
  .quality-task-resolution { align-items: stretch; flex-direction: column; }
}

/* Раскрытие строки команды на вкладке Лояльность */
.team-drill { padding: 6px 0 10px 12px; border-left: 2px solid var(--line); margin: 4px 0; }
.month-statuses { display: flex; flex-wrap: wrap; gap: 5px; min-width: 128px; }
.participant-place, .participant-points { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.participant-points { white-space: nowrap; }
