/* OKKwork — палитра для макетов «Сквозная аналитика» v2 */
:root {
  --ow-blue: #0658a2;
  --ow-blue-deep: #0369a1;
  --ow-blue-soft: #78afec;
  --ow-blue-light: #e8f2fa;
  --ow-blue-mid: #b8d4f0;
  --ow-blue-08: rgba(6, 88, 162, 0.08);
  --ow-blue-14: rgba(6, 88, 162, 0.14);
  --ow-blue-22: rgba(6, 88, 162, 0.22);
  --ow-text: #515f6c;
  --ow-text-muted: rgba(72, 87, 101, 0.72);
  --ow-bg: #f5f5f5;
  --ow-panel: #f5f5f5;
  --ow-white: #ffffff;
  --ow-green: #2eb97a;
  --ow-radius: 10px;
  --ow-shadow: 0 4px 18px rgba(6, 40, 72, 0.08);
  --ow-font: "Rubik", "Inter", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { width: 100%; }

body {
  margin: 0;
  font-family: var(--ow-font);
  color: var(--ow-text);
  background: var(--ow-bg);
  -webkit-font-smoothing: antialiased;
}

.mock-badge {
  position: fixed; top: 12px; right: 12px; z-index: 9999;
  padding: 6px 12px; border-radius: 8px;
  background: var(--ow-blue); color: #fff;
  font-size: 11px; font-weight: 600;
}

.mock-back {
  position: fixed; top: 12px; left: 12px; z-index: 9999;
  padding: 8px 14px; border-radius: 8px;
  background: var(--ow-white); border: 1px solid var(--ow-blue-22);
  color: var(--ow-blue); font-size: 13px; font-weight: 600;
  text-decoration: none; box-shadow: var(--ow-shadow);
}

.mock-back:hover { background: var(--ow-blue-08); }

.sa-page {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 64px 20px 40px;
  box-sizing: border-box;
}

.sa-toolbar-wrap,
.sa-filter-bar,
.sa-nav,
.sa-zone,
.sa-kpi-row,
.sa-row {
  width: 100%;
}

.sa-title {
  margin: 0 0 16px; font-size: 36px; font-weight: 600;
  color: var(--ow-blue); letter-spacing: 0.02em;
}

/* ——— Toolbar (скрин 3) ——— */
.sa-toolbar-wrap { margin-bottom: 16px; }

.sa-toolbar-tabs {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}

.sa-toolbar-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 14px; border-radius: 8px; border: none;
  background: var(--ow-blue-light); color: var(--ow-blue);
  font-size: 13px; font-weight: 600; cursor: pointer;
}

.sa-toolbar-tab.is-active {
  background: var(--ow-blue); color: #fff;
}

.sa-toolbar-tab__x { opacity: 0.8; font-size: 14px; }

.sa-toolbar-tab--add {
  background: var(--ow-blue-light); color: var(--ow-blue);
  padding: 6px 12px; font-size: 18px; line-height: 1;
}

.sa-filter-bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px;
  padding: 14px 18px; border-radius: var(--ow-radius);
  background: var(--ow-blue-light);
  border: 1px solid var(--ow-blue-mid);
}

.sa-filter-bar__fields {
  display: flex; flex-wrap: wrap; gap: 16px; flex: 1;
}

.sa-filter-bar__field { min-width: 160px; }

.sa-filter-bar__label {
  display: block; margin-bottom: 6px;
  font-size: 12px; font-weight: 700; color: var(--ow-blue);
}

.sa-filter-bar__label a {
  font-weight: 400; color: var(--ow-blue-soft); text-decoration: none;
}

.sa-filter-bar__select {
  width: 100%; height: 40px; padding: 0 10px;
  border-radius: 8px; border: 1px solid var(--ow-blue-mid);
  background: #fff; color: var(--ow-text); font: inherit; font-size: 13px;
}

.sa-filter-bar__select--badge {
  display: flex; align-items: center; gap: 8px;
}

.sa-filter-bar__badge {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ow-blue); color: #fff;
  font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}

.sa-nav {
  display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px;
}

.sa-nav__item {
  padding: 7px 25px; border-radius: var(--ow-radius);
  font-size: 14px; font-weight: 600; letter-spacing: 0.12em;
  border: none; cursor: pointer;
  background: var(--ow-blue-light); color: var(--ow-blue);
}

.sa-nav__item:hover:not(.is-active) {
  background: var(--ow-blue-08);
}

.sa-nav__item.is-active {
  background: var(--ow-blue); color: #fafafa;
}

.sa-panel {
  width: 100%;
  box-sizing: border-box;
  background: var(--ow-panel); border-radius: var(--ow-radius); padding: 20px;
}

.sa-tab-panel { display: none; }
.sa-tab-panel.is-active { display: block; }

.sa-stub {
  text-align: center; padding: 80px 24px;
  background: #fff; border-radius: var(--ow-radius);
  border: 1px dashed var(--ow-blue-mid);
}

.sa-stub p {
  margin: 0; font-size: 18px; font-weight: 500; color: var(--ow-blue);
}

/* ——— Зоны (макет 19) ——— */
.sa-zone { margin-bottom: 24px; }

.sa-zone__head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 14px; padding-bottom: 8px;
  border-bottom: 2px solid var(--ow-blue);
}

.sa-zone__head h2 {
  margin: 0; font-size: 14px; font-weight: 700;
  letter-spacing: 0.12em; color: var(--ow-blue);
}

.sa-zone__badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; background: var(--ow-blue-08); color: var(--ow-blue);
}

.sa-card {
  background: var(--ow-white); border: 1px solid rgba(6, 88, 162, 0.12);
  border-radius: var(--ow-radius); padding: 14px 16px;
}

.sa-card__label {
  margin: 0 0 6px; font-size: 11px; font-weight: 600;
  letter-spacing: 0.1em; color: var(--ow-text-muted); text-transform: uppercase;
}

.sa-card__value {
  margin: 0; font-size: 28px; font-weight: 700; color: var(--ow-blue);
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}

.sa-card__unit {
  font-size: 14px; font-weight: 600; color: var(--ow-text-muted);
}

.sa-card__sub {
  margin: 6px 0 0; font-size: 11px;
  color: var(--ow-text-muted); line-height: 1.35;
}

.sa-kpi-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px;
}

.sa-kpi-row--general-all {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
}

.sa-kpi-row--general-all > .sa-card:nth-child(-n+3) {
  padding: 10px 12px;
}

.sa-kpi-row--general-all > .sa-card:nth-child(-n+3) .sa-card__value {
  font-size: 22px;
}

.sa-kpi-row--general-all > .sa-card:nth-child(-n+3) .sa-card__title {
  font-size: 10px;
  letter-spacing: 0.02em;
}

.sa-kpi-row--general-top {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 520px;
  margin-top: 12px;
}

.sa-kpi-row--pf {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sa-kpi-row--mkk {
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(168px, 1fr);
  align-items: stretch;
}

.sa-kpi-row--mkk > .sa-card,
.sa-kpi-row--mkk > .sa-chart--gauge {
  height: 100%;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.sa-kpi-row--mkk .sa-card {
  justify-content: flex-start;
}

.sa-kpi-row--mkk .sa-card__value {
  font-size: 24px;
}

.sa-kpi-row--mkk .sa-chart--gauge {
  align-self: stretch;
  padding: 14px 16px;
  min-height: 148px;
}

.sa-chart--gauge {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sa-chart--gauge .sa-chart__title {
  margin-bottom: 2px;
}

.sa-chart--gauge .sa-chart__desc {
  margin-bottom: 6px;
}

.sa-chart--gauge .sa-chart__body {
  flex: 1 1 auto;
  min-height: 72px;
  max-height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sa-gauge-svg {
  width: 100%;
  max-width: 140px;
  height: auto;
  min-height: 0;
  max-height: 80px;
  display: block;
}

.sa-chart--full { width: 100%; }

.sa-chart--combo.sa-chart--line {
  min-height: 0;
}

.sa-chart__head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.sa-chart-gran {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  flex: 1 1 100%;
  max-width: 100%;
}

.sa-chart-gran__btn {
  border: 1px solid rgba(6, 88, 162, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: #515f6c;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
}

.sa-chart-gran__btn.is-active,
.sa-chart-gran__btn:hover {
  background: rgba(6, 88, 162, 0.12);
  border-color: rgba(6, 88, 162, 0.45);
  color: #0658a2;
}

.sa-chart__head-text {
  flex: 1;
  min-width: 0;
}

.sa-chart__head-row .sa-chart__title,
.sa-chart__head-row .sa-chart__desc {
  margin-bottom: 0;
}

.sa-chart__head-row .sa-chart__desc {
  margin-top: 2px;
}

.sa-pf-view-toggle {
  margin-top: 0;
  flex-shrink: 0;
}

.sa-chart__body--pf {
  position: relative;
}

.sa-chart__body--pf .sa-chart__line-stack {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

.sa-chart__body--pf .sa-pf-chart-pane.is-active {
  flex: 1 1 auto;
  min-height: 220px;
}

.sa-line-legend--pf {
  flex-shrink: 0;
}

.sa-pf-chart-pane {
  width: 100%;
  height: 100%;
  display: none;
  overflow-x: auto;
  overflow-y: hidden;
}

.sa-pf-chart-pane.is-active {
  display: block;
}

.sa-pf-chart-pane[hidden] {
  display: none !important;
}

.sa-chart--combo .sa-chart__body {
  flex: 1 1 auto;
  min-height: 240px;
  height: auto;
  max-height: none;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.sa-chart--combo .sa-chart-svg {
  flex: 1 1 auto;
  width: 100%;
  height: auto;
  min-height: 220px;
  max-height: none;
}

.sa-row {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  width: 100%;
  align-items: start;
}

.sa-row--combo { grid-template-columns: repeat(3, 1fr); }
.sa-row--dyn { grid-template-columns: 1fr 1fr; }
.sa-row--blocks { grid-template-columns: repeat(3, 1fr); }
.sa-row--mkk {
  grid-template-columns: repeat(3, 1fr);
  align-items: stretch;
}

.sa-row--mkk > .sa-chart {
  min-height: 280px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.sa-row--mkk > .sa-chart .sa-chart__body {
  flex: 1 1 auto;
  min-height: 220px;
}

.sa-row--mkk > .sa-chart--donut .sa-chart__body--donut {
  min-height: 220px;
  align-content: center;
}

.sa-row--mkk > .sa-chart:has(.sa-chart__body--hbar) .sa-chart__body--hbar {
  max-height: none;
  min-height: 220px;
}

.sa-chart {
  background: var(--ow-white); border: 1px solid rgba(6, 88, 162, 0.12);
  border-radius: var(--ow-radius); padding: 12px 14px;
  min-height: 0; display: flex; flex-direction: column;
}

.sa-chart--donut {
  padding: 10px 12px;
}

.sa-chart__title {
  margin: 0 0 2px; font-size: 12px; font-weight: 600;
  color: var(--ow-blue);
}

.sa-chart__desc {
  margin: 0 0 8px; font-size: 10px;
  color: var(--ow-text-muted); line-height: 1.3;
}

.sa-chart__body {
  flex: 1; width: 100%; min-height: 0;
  display: flex; align-items: stretch; justify-content: stretch;
}

.sa-chart__body--donut {
  display: grid; grid-template-columns: auto max-content;
  gap: 10px 12px; align-items: center;
  min-height: 0;
}

.sa-chart__donut-ring {
  display: flex; align-items: center; justify-content: center;
  width: 116px; flex-shrink: 0;
}

.sa-donut-svg { width: 116px; height: 116px; max-height: 116px; }

.sa-donut-legend {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 5px;
}

.sa-donut-legend__item {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--ow-text); cursor: pointer;
  padding: 2px 4px; border-radius: 4px;
}

.sa-donut-legend__item:hover { background: var(--ow-blue-08); }

.sa-donut-legend__item.is-active {
  background: var(--ow-blue-08); box-shadow: inset 0 0 0 1px var(--ow-blue-14);
}

.sa-donut-legend__name { font-weight: 500; }

.sa-donut-legend__avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--ow-blue); color: #fff;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; text-transform: lowercase;
}

.sa-donut-legend__val {
  color: var(--ow-text-muted); font-size: 11px; margin-left: 4px;
}

.sa-chart__line-stack {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.sa-chart__line-stack > .sa-chart-svg {
  flex: 1 1 auto;
  min-height: 180px;
}

.sa-chart__line-stack > .sa-chart-svg.sa-chart-svg--gran,
.sa-chart__body--pf .sa-pf-chart-pane > .sa-chart-svg.sa-chart-svg--gran,
.sa-chart--line .sa-chart-svg.sa-chart-svg--gran,
.sa-chart--full .sa-chart-svg.sa-chart-svg--gran,
.sa-row--dyn .sa-chart--line .sa-chart-svg.sa-chart-svg--gran {
  flex: 1 1 auto !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: none !important;
}

.sa-chart__line-stack > .sa-chart-svg.sa-chart-svg--daily,
.sa-chart__body--pf .sa-pf-chart-pane > .sa-chart-svg.sa-chart-svg--daily,
.sa-chart--line .sa-chart-svg.sa-chart-svg--daily,
.sa-chart--full .sa-chart-svg.sa-chart-svg--daily,
.sa-row--dyn .sa-chart--line .sa-chart-svg.sa-chart-svg--daily {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 260px !important;
  max-height: 280px !important;
}

.sa-row--dyn .sa-chart--line .sa-chart-svg.sa-chart-svg--daily {
  height: 240px !important;
  max-height: 260px !important;
}

.sa-line-legend {
  list-style: none;
  margin: 0;
  padding: 10px 6px 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  border-top: 1px solid rgba(6, 88, 162, 0.1);
}

.sa-line-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--ow-blue-08);
  font-size: 11px;
  font-weight: 600;
  color: var(--ow-text);
  cursor: pointer;
}

.sa-line-legend__item:hover,
.sa-line-legend__item.is-active {
  background: var(--ow-blue-14);
}

.sa-line-legend__swatch {
  width: 16px;
  height: 2.5px;
  border-radius: 999px;
  flex-shrink: 0;
}

.sa-line-legend__swatch--dash {
  background: transparent !important;
  height: 0;
  border-bottom: 2.5px dashed;
  border-radius: 0;
}

.sa-line-legend__label {
  color: #515f6c;
}

.sa-chart__body--hbar {
  min-height: 0;
  align-items: stretch;
  max-height: 132px;
  overflow: auto;
}

.sa-hbar {
  list-style: none; margin: 0; padding: 0; width: 100%;
  display: flex; flex-direction: column; gap: 10px;
}

.sa-hbar__row {
  display: grid; grid-template-columns: minmax(96px, 1fr) 1.2fr auto;
  align-items: center; gap: 8px;
}

.sa-hbar__person {
  display: flex; align-items: center; gap: 6px; min-width: 0;
}

.sa-hbar__name {
  font-size: 11px; font-weight: 500; color: var(--ow-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sa-hbar__track {
  height: 14px; background: var(--ow-blue-08); border-radius: 4px; overflow: hidden;
  min-width: 0;
}

.sa-hbar__fill {
  display: block; height: 100%; background: var(--ow-blue); border-radius: 4px;
  min-width: 2px;
}

.sa-hbar__val {
  font-size: 11px; font-weight: 700; color: var(--ow-blue);
  min-width: 40px; text-align: right;
}

.sa-chart--donut .sa-chart__body--hbar,
.sa-chart:has(.sa-chart__body--hbar) {
  min-height: 0;
}

.sa-chart:has(.sa-chart__body--hbar) .sa-chart__body--hbar {
  max-height: 128px;
}

.sa-chart--line {
  min-height: 280px;
}

.sa-chart--line .sa-chart__desc {
  margin-bottom: 6px;
}

.sa-chart--line .sa-chart__body {
  flex: 1 1 auto;
  min-height: 220px;
  display: flex;
  align-items: stretch;
}

.sa-chart--line .sa-chart-svg {
  flex: 1 1 auto;
  width: 100%;
  height: 100%;
  min-height: 220px;
  max-height: none;
}

.sa-chart--full.sa-chart--line {
  min-height: 340px;
}

.sa-chart--full.sa-chart--line .sa-chart__body {
  min-height: 300px;
}

.sa-chart--full .sa-chart-svg {
  min-height: 300px;
  max-height: none;
}

.sa-row--dyn .sa-chart--line {
  min-height: 300px;
}

.sa-row--dyn .sa-chart--line .sa-chart__body {
  min-height: 240px;
}

.sa-row--dyn .sa-chart--line .sa-chart-svg {
  min-height: 240px;
}

.sa-chart svg,
.sa-chart-svg {
  width: 100%; height: auto; min-height: 0; max-height: 440px;
  display: block;
  border-radius: 8px;
}

.sa-chart--line svg,
.sa-chart--line .sa-chart-svg {
  height: auto;
  max-height: none;
}

@media (max-width: 1100px) {
  .sa-kpi-row { grid-template-columns: repeat(3, 1fr); }
  .sa-kpi-row--general-all { grid-template-columns: repeat(3, 1fr); }
  .sa-kpi-row--general-top { max-width: none; grid-template-columns: repeat(2, 1fr); }
  .sa-kpi-row--pf { grid-template-columns: repeat(3, 1fr); }
  .sa-kpi-row--mkk { grid-template-columns: repeat(2, 1fr); }
  .sa-kpi-row--mkk > .sa-chart--gauge { grid-column: 1 / -1; max-width: none; justify-self: stretch; }
}

@media (max-width: 700px) {
  .sa-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .sa-chart__body--donut { grid-template-columns: 1fr; }
}
