@import url('/vendor/roboto/roboto.css');

:root {
  --primary: #ED1C24;
  --primary-dark: #c2161c;
  --bg: #f4f4f4;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-strong: #d7dce5;
  --sidebar-w: 240px;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow: 0 .125rem .35rem rgba(15, 23, 42, .08);
  font-family: "Roboto", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #050505;
  color: #fff;
  transition: transform .25s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .18);
}

.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.brand-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  line-height: 1.1;
}

.brand-text strong {
  font-size: 14px;
}

.brand-text small {
  color: rgba(255, 255, 255, .52);
  font-size: 11px;
}

.nav {
  flex: 1;
  padding: 8px 0;
}

.nav-group {
  padding: 13px 18px 5px;
  color: rgba(255, 255, 255, .48);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 8px 18px 8px 15px;
  background: transparent;
  color: rgba(255, 255, 255, .58);
  text-align: left;
  font-size: 13.5px;
  transition: color .15s, background .15s, border-color .15s;
}

.nav button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .07);
}

.nav button.active {
  color: #fff;
  background: rgba(237, 28, 36, .12);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav .bi {
  width: 16px;
  color: inherit;
  opacity: .72;
  font-size: 15px;
}

.nav button.active .bi {
  opacity: 1;
}

.sidebar-footer {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, .18);
}

.sidebar-footer label,
.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.sidebar-footer label {
  color: rgba(255, 255, 255, .38);
}

select,
input,
textarea {
  width: 100%;
  min-height: 31px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 5px 9px;
  background: #fff;
  color: var(--ink);
  outline: 0;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(237, 28, 36, .12);
}

.workspace {
  min-height: 100vh;
  margin-left: var(--sidebar-w);
  background: var(--bg);
}

.icon-button {
  position: relative;
  width: 31px;
  height: 31px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 0;
  background: #fff;
  color: #374151;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.icon-button:hover {
  border-color: #c9d2df;
  background: #f8fafc;
}

.icon-button .bi-list {
  font-size: 19px;
  line-height: 1;
}

.notif-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--primary);
}

.mobile-menu-btn {
  display: none;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 6px;
  border-left: 1px solid var(--line);
}

.user-avatar {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.user-chip span:last-child {
  display: grid;
  gap: 1px;
  line-height: 1.05;
}

.user-chip strong {
  font-size: 13px;
  font-weight: 500;
}

.user-chip small {
  color: var(--muted);
  font-size: 11px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 0;
  padding: 12px 24px 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: #888;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
  font-weight: 700;
}

h2,
h3 {
  margin: 0;
}

.page-subtitle {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.page-actions,
.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.primary-button,
.ghost-button {
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 5px 10px;
  font-size: 13px;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}

.primary-button {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.ghost-button {
  border-color: var(--line-strong);
  background: #fff;
  color: #374151;
}

.ghost-button:hover {
  background: #f8fafc;
}

.rule-actions-cell {
  width: 1%;
  white-space: nowrap;
}

.action-menu {
  position: relative;
  display: inline-block;
}

.action-menu-toggle {
  list-style: none;
  cursor: pointer;
}

.action-menu-toggle::-webkit-details-marker {
  display: none;
}

.action-menu-toggle .bi-list {
  font-size: 20px;
}

.action-menu[open] .action-menu-toggle {
  border-color: #c9d2df;
  background: #f8fafc;
}

.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  bottom: auto;
  z-index: 20;
  min-width: 180px;
  display: none;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .16);
}

.action-menu[open] .action-menu-panel {
  display: grid;
  gap: 2px;
}

.action-menu.menu-up .action-menu-panel {
  top: auto;
  bottom: calc(100% + 6px);
}

.action-menu-item {
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 0;
  padding: 8px 10px;
  background: transparent;
  color: var(--ink);
  justify-content: flex-start;
  text-align: left;
  box-shadow: none;
}

.action-menu-item:hover {
  background: #f3f4f6;
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 0 24px 16px;
}

.field-wide {
  grid-row: span 2;
}

.field {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-self: start;
}

.field-checkdrop {
  min-width: 0;
  position: relative;
}

.check-dropdown {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  position: relative;
}

.check-dropdown summary {
  width: 100%;
  min-height: 31px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 5px 9px;
  background: #fff;
  color: var(--ink);
  list-style: none;
  cursor: pointer;
  overflow: hidden;
}

.check-dropdown summary::-webkit-details-marker {
  display: none;
}

.check-dropdown[open] summary {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(237, 28, 36, .12);
}

.check-dropdown-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-dropdown-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  z-index: 30;
  display: grid;
  gap: 2px;
  max-height: 240px;
  overflow-y: auto;
  min-width: 0;
  max-width: 100%;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, .16);
}

.field .check-dropdown-option {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 13px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}

.field .check-dropdown-option:hover {
  background: #f3f4f6;
}

.field .check-dropdown-option input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.field .check-dropdown-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-picker .picker-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.field-picker .picker-row input {
  flex: 1;
  min-width: 0;
}

.field-picker .picker-row .ghost-button {
  flex: 0 0 auto;
  align-self: flex-start;
}

.field-picker .chips {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 8px;
  border: 1px solid var(--border, #d1d5db);
  border-radius: 6px;
  background: #fff;
  min-height: 36px;
  max-height: 96px;
  overflow-y: auto;
}

.field-picker .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px 2px 8px;
  background: #eef2ff;
  color: #1e3a8a;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.field-picker .chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
  border-radius: 50%;
}

.field-picker .chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
}

.content {
  display: grid;
  gap: 16px;
  padding: 0 24px 28px;
}

.data-freshness {
  margin-top: -12px;
  padding: 0 24px 24px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.kpi,
.panel,
.card {
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi {
  min-height: 116px;
  padding: 18px;
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
}

.kpi strong {
  display: block;
  margin-top: 9px;
  font-size: 28px;
  line-height: 1.1;
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel-header h2 {
  font-size: 16px;
  font-weight: 700;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.compact-table {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.compact-table table {
  min-width: 560px;
}

.compact-table th,
.compact-table td {
  padding: .58rem .7rem;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: .72rem .85rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #4b5563;
  background: #f8f9fa;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

tr:hover td {
  background: #fcfcfc;
}

.network-sales-cell {
  color: var(--primary);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.network-sales-cell:hover,
.network-sales-cell:focus,
.network-sales-cell.is-open {
  background: #fff5f5;
  box-shadow: inset 0 0 0 2px rgba(237, 28, 36, .24);
  outline: none;
}

.network-sales-breakdown {
  position: fixed;
  z-index: 1060;
  width: min(640px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 24px));
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 18px 48px rgba(15, 23, 42, .18);
}

.breakdown-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.breakdown-head strong,
.breakdown-head span {
  display: block;
}

.breakdown-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.breakdown-close {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.breakdown-close:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.breakdown-logic {
  margin: 0;
  padding: 12px 14px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.breakdown-total {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}

.breakdown-total span {
  color: var(--muted);
  font-size: 12px;
}

.breakdown-total strong {
  color: #111827;
  font-size: 16px;
}

.breakdown-table-wrap {
  max-height: 340px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.breakdown-table-wrap table {
  min-width: 0;
}

.breakdown-table-wrap th,
.breakdown-table-wrap td {
  padding: .58rem .7rem;
  font-size: 13px;
}

.breakdown-table-wrap td:nth-child(2) {
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 600;
  background: #f0f0f0;
  color: #555;
  white-space: nowrap;
}

.badge.high {
  background: #fff0f0;
  color: var(--primary);
}

.badge.medium {
  background: #fffbeb;
  color: #d97706;
}

.badge.ok {
  background: #f0fdf4;
  color: #16a34a;
}

.badge.paused {
  background: #eff6ff;
  color: #2563eb;
}

.progress {
  height: 8px;
  min-width: 110px;
  margin-bottom: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #eceff3;
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

/* Compare-строки (прошлый период, прошлогодний) */
tr.compare-row {
  background: #f7f8fa;
}

tr.compare-row td {
  color: var(--muted);
}

.analytics-manager-cell {
  vertical-align: top;
  font-weight: 600;
}

.row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}

.row-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.bars {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.indicator-manager {
  padding: 14px 18px 4px;
  border-top: 1px solid var(--border, #eceff3);
}

.indicator-manager:first-of-type {
  border-top: none;
}

.indicator-manager h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.indicator-manager .bars {
  padding: 6px 0 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 74px minmax(120px, 1fr) 70px;
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.bar-track {
  height: 24px;
  overflow: hidden;
  border-radius: var(--radius);
  background: #f0f0f0;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: rgba(237, 28, 36, .82);
}

.entity-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}

.entity-link:hover {
  text-decoration: underline;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 16px;
}

.card {
  padding: 16px;
}

.card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.detail-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.detail {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.detail-lead {
  border-color: rgba(237, 28, 36, .24);
  background: rgba(237, 28, 36, .04);
}

.detail span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1080;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .50);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .24);
}

.modal header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.modal h2 {
  font-size: 18px;
}

#modalBody {
  padding: 16px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.modal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.modal-tabs button {
  min-height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  background: #fff;
  color: #374151;
}

.modal-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.modal-tab-panel {
  display: grid;
  gap: 12px;
}

.modal-tab-panel[hidden] {
  display: none;
}

.rule-form h3 {
  margin-top: 8px;
  font-size: 15px;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  font: inherit;
}

.link-button.entity-link {
  color: var(--primary);
}

.switch-field,
.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.switch-field {
  min-height: 64px;
  padding: 12px;
}

.switch-field input,
.check-field input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--primary);
}

.switch-field span {
  display: grid;
  gap: 3px;
}

.switch-field small {
  color: var(--muted);
  font-size: 12px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-field {
  min-height: 38px;
  padding: 8px 10px;
}

.empty {
  padding: 22px;
  color: var(--muted);
}

.plan-errors {
  border-color: rgba(237, 28, 36, .28);
}

.plan-error-list {
  display: grid;
  gap: 10px;
  padding: 16px 18px 18px;
}

.plan-error {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid rgba(237, 28, 36, .28);
  border-radius: var(--radius-lg);
  background: rgba(237, 28, 36, .06);
  color: var(--ink);
}

.plan-error strong {
  color: var(--primary-dark);
}

.plan-error span {
  color: var(--muted);
  line-height: 1.45;
}

.plan-correctness {
  display: inline-flex;
  align-items: center;
  gap: .45em;
}

.plan-correctness-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35em;
  height: 1.35em;
  font-size: 1em;
  line-height: 1;
  border-radius: 999px;
  background: #f6f7f9;
}

.plan-correctness-mark.is-ok {
  background: #f0fdf4;
}

.plan-correctness-mark.is-bad {
  background: #fff1f2;
}

.demo-page {
  min-height: 100vh;
  padding: 24px;
  background: var(--bg);
}

.demo-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.demo-actions[hidden] {
  display: none;
}

.demo-notice {
  margin: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(220, 38, 38, .24);
  border-radius: 16px;
  color: #991b1b;
  background: rgba(254, 226, 226, .72);
}

.demo-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 16px 0;
}

.demo-tabs button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 6px 12px;
  background: #fff;
  color: #374151;
}

.demo-tabs button.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.demo-tabs .link-button {
  margin-left: auto;
}

.demo-section {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.demo-section[hidden] {
  display: none;
}

.demo-section h3 {
  margin: 0;
}

.demo-migration-list,
.demo-history-list {
  display: grid;
  gap: 12px;
}

.demo-migration-card,
.demo-history-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
}

.demo-migration-card h4 {
  margin: 0 0 6px;
}

.demo-migration-card p,
.demo-history-card p {
  margin: 0;
  color: var(--muted);
}

.demo-migration-card small {
  display: inline-flex;
  margin-top: 8px;
  color: var(--muted);
}

.demo-migration-run {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
}

.demo-migration-run .primary-button {
  width: 168px;
  height: 31px;
  min-height: 31px;
}

.demo-migration-status {
  max-width: 260px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.demo-migration-status:empty {
  display: none;
}

.demo-migration-status[data-status="progress"] {
  color: #d97706;
}

.demo-migration-status[data-status="success"] {
  color: #16a34a;
}

.demo-migration-status[data-status="failed"] {
  color: var(--primary);
}

.demo-migration-progress {
  display: grid;
  box-sizing: border-box;
  width: 168px;
  height: 31px;
  min-height: 31px;
  align-content: center;
  gap: 3px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}

.demo-migration-progress[hidden] {
  display: none;
}

.demo-migration-progress__track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}

.demo-migration-progress__track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: #2563eb;
  transition: width 0.2s ease;
}

.demo-migration-progress__meta {
  color: var(--muted);
  overflow: hidden;
  font-size: 11px;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-history-card {
  align-items: center;
}

.demo-history-card > div {
  display: grid;
  gap: 4px;
}

.demo-history-card span:not(.badge) {
  color: var(--muted);
  font-size: 13px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.link-button.rule-name-link {
  color: var(--ink);
  font-weight: 700;
  text-align: left;
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link-button.rule-name-link:hover {
  color: var(--primary);
}

button:disabled,
.primary-button:disabled,
.ghost-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: .48;
  filter: grayscale(.35);
  box-shadow: none;
  transform: none;
}

button:disabled:hover,
.primary-button:disabled:hover,
.ghost-button:disabled:hover,
.icon-button:disabled:hover {
  transform: none;
  box-shadow: none;
}

.v2-overlay {
  position: fixed;
  inset: 0;
  z-index: 1035;
  display: none;
  background: rgba(0, 0, 0, .50);
}

.v2-overlay.open {
  display: block;
}

@media (max-width: 991px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: inline-flex;
  }

  .filters,
  .kpi-grid,
  .split,
  .details-grid,
  .checkbox-grid {
    grid-template-columns: 1fr;
  }

  .page-head {
    flex-direction: column;
    padding: 20px 16px 14px;
  }

  .filters,
  .content {
    padding-left: 16px;
    padding-right: 16px;
  }

  .data-freshness {
    padding-left: 16px;
    padding-right: 16px;
    text-align: left;
  }

}

@media (max-width: 640px) {
  .user-chip span:last-child {
    display: none;
  }

  h1 {
    font-size: 24px;
  }

  .demo-migration-card {
    display: grid;
  }

  .demo-migration-run {
    justify-content: flex-end;
  }

  .demo-migration-progress {
    width: min(100%, 168px);
  }
}

/* ---------- Линейный график (Продажи дилерской сети) ---------- */

.bar-chart {
  position: relative;
  padding: 16px 18px 6px;
  max-width: 900px;
  margin: 0 auto;
}

.bar-chart svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.bar-chart-grid {
  stroke: var(--line);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.bar-chart-bar {
  cursor: pointer;
  transition: opacity 0.12s ease;
}

.bar-chart-bar:hover {
  opacity: 0.8;
}

.bar-chart-bar.sales {
  fill: var(--primary);
}

.bar-chart-bar.plan {
  fill: #94a3b8;
}

.bar-chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.bar-chart-line.sales {
  stroke: var(--primary);
}

.bar-chart-line.plan {
  stroke: #94a3b8;
}

.bar-chart-tick {
  fill: var(--muted);
  font-size: 11px;
  font-family: "Roboto", Arial, sans-serif;
}

.bar-chart-tooltip {
  position: absolute;
  transform: translate(-50%, -100%);
  background: var(--ink);
  color: #fff;
  padding: 6px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow);
  z-index: 5;
}

.bar-chart-tooltip::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: var(--ink);
}

.bar-chart-tooltip strong {
  font-weight: 600;
}

.bar-chart-legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 8px 0 4px;
}

.bar-chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.bar-chart-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.bar-chart-swatch.sales {
  background: var(--primary);
}

.bar-chart-swatch.plan {
  background: #94a3b8;
}

.bar-chart-empty {
  padding: 32px 18px;
  color: var(--muted);
  text-align: center;
}

/* Заголовки таблиц с подсказкой (native title) — визуально подсвечены пунктиром, */
/* чтобы пользователь видел, что у колонки есть описание. */
th[title] {
  cursor: help;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
}

/* Вкладки-группы над BI-таблицами (Основные показатели / Платежная дисциплина / ...). */
.table-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px 4px;
}

.table-tabs button {
  background: var(--bg-subtle, #f3f4f6);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.table-tabs button:hover {
  background: #e5e7eb;
}

.table-tabs button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------- App loader (глобальный спинер при перезагрузке данных) ---------- */
.app-loader {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  z-index: 1050; /* выше .v2-overlay (1035) и .sidebar (1040), ниже .modal-backdrop (1080) */
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* блокировку интерактива делает body.is-loading через main/aside */
  background: rgba(244, 244, 244, .35);
}

body.is-loading .app-loader { display: flex; }

.app-loader__spinner {
  width: 56px;
  height: 56px;
  border: 5px solid rgba(237, 28, 36, .18); /* --primary с прозрачностью */
  border-top-color: var(--primary);          /* #ED1C24 */
  border-radius: 50%;
  animation: app-loader-spin .8s linear infinite;
}

@keyframes app-loader-spin { to { transform: rotate(360deg); } }

body.is-loading main.workspace {
  filter: blur(2px);
  pointer-events: none;
  user-select: none;
}

body.is-loading aside.sidebar #nav,
body.is-loading aside.sidebar .brand {
  pointer-events: none;
  opacity: .55;
}

@media (max-width: 768px) {
  .app-loader { left: 0; }
}

/* ---------- Role mapping (вкладка «Маппинг ролей» на «Настройках») ---------- */
.role-mapping-intro {
  color: var(--muted);
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
}
.role-mapping-intro code {
  background: #eef2ff;
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.role-mapping-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fff;
}
.role-mapping-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 12px;
}
.role-mapping-block__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 28px;
}
.role-mapping-block .chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 4px 3px 10px;
  background: #eef2ff;
  color: #1e3a8a;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
}
.role-mapping-block .chip small {
  font-size: 11px;
  opacity: .75;
}
.role-mapping-block .chip-remove {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 6px;
  border-radius: 50%;
}
.role-mapping-block .chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
}
.role-mapping-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}
