/* Экран дашборда. База — в styles.css, здесь только раскладка и блоки. */

html, body.dash { height: 100%; }

body.dash {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------- шапка ---------- */

.dash .top { flex: 0 0 auto; position: static; padding: 12px 24px; }

.top-mid { display: flex; align-items: center; gap: 14px; }

.month-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.month-picker select {
  width: auto;
  padding: 5px 10px;
  font-family: var(--mono);
  font-size: 13px;
  background: #0b0f13;
}

/* ---------- KPI ---------- */

.kpi {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.kpi-chip {
  background: var(--panel);
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
  border: 0;
  border-radius: 0;
  color: inherit;
  cursor: default;
  font: inherit;
}

.kpi-chip[data-clickable="1"] { cursor: pointer; }
.kpi-chip[data-clickable="1"]:hover { background: var(--panel-2); }
.kpi-chip[data-active="1"] { box-shadow: inset 0 -2px 0 var(--accent); }

.kpi-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-value {
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.kpi-value small { font-size: 12px; color: var(--muted); font-family: inherit; }
.kpi-value[data-tone="bad"] { color: var(--bad); }
.kpi-value[data-tone="warn"] { color: var(--warn); }
.kpi-value[data-tone="ok"] { color: var(--accent); }

/* exec-режим: полоса распределения и проверка гипотезы */

.kpi-extra {
  display: none;
  flex: 0 0 auto;
  gap: 20px;
  align-items: center;
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: #10151a;
  font-size: 12.5px;
}

body[data-view="exec"] .kpi-extra { display: flex; }

.bands-bar {
  display: flex;
  height: 8px;
  width: 240px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.bands-bar span { display: block; height: 100%; }
.bands-bar .low { background: var(--accent); }
.bands-bar .watch { background: var(--warn); }
.bands-bar .critical { background: var(--bad); }

.hypothesis b { font-family: var(--mono); font-weight: 600; }

/* ---------- раскладка ---------- */

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 392px minmax(0, 1fr);
}

.rail {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #10151a;
}

.rail-tools {
  flex: 0 0 auto;
  padding: 9px 12px 8px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.rail-tools input[type="search"] {
  width: 100%;
  padding: 6px 10px;
  background: #0b0f13;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}

.segmented, .filters {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.segmented button, .filters button {
  flex: 1 1 auto;
  padding: 4px 8px;
  font-size: 11.5px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 500;
}

.segmented button.active, .filters button.active {
  color: var(--text);
  border-color: rgba(76, 201, 164, 0.4);
  background: rgba(76, 201, 164, 0.1);
}

.filters button { flex: 0 1 auto; }

.list {
  flex: 1 1 auto;
  gap: 4px;
  min-height: 120px;
  overflow-y: auto;
  padding: 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.list-empty { padding: 22px 12px; color: var(--muted); font-size: 13px; }

.row-person {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.row-person:hover { background: rgba(255, 255, 255, 0.03); }

.row-person[aria-selected="true"] {
  background: rgba(76, 201, 164, 0.08);
  border-color: rgba(76, 201, 164, 0.35);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  color: #0b0f13;
  background: var(--accent);
}

.row-main { min-width: 0; }

.row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-right { display: flex; align-items: center; gap: 8px; }

.row-risk {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 600;
  min-width: 30px;
  text-align: right;
}

.row-risk[data-band="critical"] { color: var(--bad); }
.row-risk[data-band="watch"] { color: var(--warn); }
.row-risk[data-band="low"] { color: var(--accent); }

.delta {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.delta[data-sign="up"] { color: var(--bad); border-color: rgba(229, 83, 75, 0.45); }
.delta[data-sign="down"] { color: var(--accent); border-color: rgba(76, 201, 164, 0.4); }

.spark { display: block; }

.row-flags { display: flex; gap: 4px; margin-top: 2px; }

.flag {
  font-size: 9.5px;
  letter-spacing: 0.04em;
  padding: 0 5px;
  border-radius: 4px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.flag[data-kind="missing"] { color: var(--warn); border-color: rgba(227, 179, 65, 0.4); }
.flag[data-kind="gap"] { color: var(--bad); border-color: rgba(229, 83, 75, 0.4); }

/* ---------- низ рельса ---------- */

.rail-bottom {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 8px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 39%;
  padding-top: 7px;
  padding-bottom: 8px;
  overflow-y: auto;
}

.rail-bottom h3 {
  margin: 0 0 5px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.heatmap { display: grid; grid-template-columns: minmax(0, 1fr) repeat(6, 20px); gap: 2px; align-items: center; }

.heatmap .hm-name {
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 4px;
}

.heatmap .hm-head {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  text-align: center;
}

.hm-cell {
  height: 11px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: #0b0f13;
  cursor: pointer;
  padding: 0;
}

.hm-cell[data-band="low"] { background: rgba(76, 201, 164, 0.32); }
.hm-cell[data-band="watch"] { background: rgba(227, 179, 65, 0.4); }
.hm-cell[data-band="critical"] { background: rgba(229, 83, 75, 0.5); }
.hm-cell[data-empty="1"] { background: #0b0f13; cursor: default; }
.hm-cell[data-current="1"] { outline: 1px solid rgba(230, 237, 243, 0.55); outline-offset: 1px; }

.cause-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; padding: 3px 0; }
.cause-label { flex: 1 1 auto; min-width: 0; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cause-bar { flex: 0 0 54px; height: 3px; border-radius: 999px; background: #0b0f13; overflow: hidden; }
.cause-bar span { display: block; height: 100%; background: rgba(76, 201, 164, 0.55); }
.cause-count { flex: 0 0 auto; font-family: var(--mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; }

/* ---------- карточка ---------- */

.card {
  min-height: 0;
  overflow-y: auto;
  padding: 22px 26px 40px;
  scrollbar-gutter: stable;
}

.empty {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: 6px;
  color: var(--muted);
}
.empty-icon { font-size: 42px; color: rgba(76, 201, 164, 0.5); }
.empty h2 { margin: 0; font-size: 17px; color: var(--text); }

.card-hero {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.hero-avatar {
  width: 66px;
  height: 66px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: #0b0f13;
}

.hero-name { font-size: 22px; font-weight: 700; margin: 0 0 4px; line-height: 1.2; }
.hero-meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; }
.hero-badges { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  letter-spacing: 0.02em;
}
.badge[data-tone="critical"] { color: var(--bad); border-color: rgba(229, 83, 75, 0.45); background: rgba(229, 83, 75, 0.08); }
.badge[data-tone="watch"] { color: var(--warn); border-color: rgba(227, 179, 65, 0.45); background: rgba(227, 179, 65, 0.08); }
.badge[data-tone="low"] { color: var(--accent); border-color: rgba(76, 201, 164, 0.4); background: rgba(76, 201, 164, 0.07); }
.badge[data-dashed="1"] { border-style: dashed; }

.hero-score { text-align: right; }
.hero-risk {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}
.hero-risk[data-band="critical"] { color: var(--bad); }
.hero-risk[data-band="watch"] { color: var(--warn); }
.hero-risk[data-band="low"] { color: var(--accent); }
.hero-score small { display: block; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-top: 3px; }
.hero-delta { margin-top: 6px; display: flex; justify-content: flex-end; }

.block { margin-top: 22px; }
.block > h3 {
  margin: 0 0 9px;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.block > h3 button.linklike { font-size: 11px; letter-spacing: 0; text-transform: none; }

.summary-text { font-size: 14px; line-height: 1.55; margin: 0; }
.blockquote {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-left: 2px solid rgba(76, 201, 164, 0.5);
  background: rgba(76, 201, 164, 0.05);
  font-size: 12.5px;
  color: var(--muted);
  border-radius: 0 8px 8px 0;
}

/* разрыв */

.gap-grid { display: flex; flex-direction: column; gap: 7px; }

.gap-row {
  display: grid;
  grid-template-columns: 132px 1fr 92px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.gap-name { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.gap-bars { display: flex; flex-direction: column; gap: 3px; }

.gap-bar { height: 6px; border-radius: 999px; background: #0b0f13; overflow: hidden; }
.gap-bar span { display: block; height: 100%; }
.gap-bar[data-side="intern"] span { background: rgba(76, 201, 164, 0.75); }
.gap-bar[data-side="mentor"] span { background: rgba(120, 160, 220, 0.75); }

.gap-values { font-family: var(--mono); font-size: 11px; color: var(--muted); text-align: right; white-space: nowrap; }
.gap-values[data-gap="1"] { color: var(--bad); }

.gap-legend { display: flex; gap: 14px; font-size: 11px; color: var(--muted); margin-top: 8px; }
.gap-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.gap-legend .i-intern { background: rgba(76, 201, 164, 0.75); }
.gap-legend .i-mentor { background: rgba(120, 160, 220, 0.75); }

/* причины и шаги */

.reason, .step {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.reason:first-child, .step:first-child { border-top: 0; padding-top: 2px; }

.reason-points, .step-points {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  color: var(--bad);
  padding-top: 1px;
}
.step-points { color: var(--accent); }

.reason-title { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.reason-text { font-size: 12.5px; color: var(--muted); }
.reason .blockquote { margin-top: 6px; }

.step-title { font-size: 13px; line-height: 1.4; }
.step-meta { margin-top: 4px; font-size: 11.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }

.signals { display: flex; flex-wrap: wrap; gap: 6px; }
.signal-chip {
  font-size: 11.5px;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px dashed rgba(229, 83, 75, 0.5);
  color: #e5a09b;
  background: rgba(229, 83, 75, 0.06);
}

/* график */

.chart-wrap { border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px 6px; background: #0d1217; }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-family: var(--mono); font-size: 10px; fill: var(--muted); }
.chart .axis { stroke: rgba(255, 255, 255, 0.06); }
.chart .band-critical { fill: rgba(229, 83, 75, 0.06); }
.chart .band-watch { fill: rgba(227, 179, 65, 0.05); }
.chart .history { fill: none; stroke: var(--text); stroke-width: 2; }
.chart .history-dot { fill: var(--bg); stroke: var(--text); stroke-width: 2; }
.chart .base { fill: none; stroke: var(--bad); stroke-width: 2; stroke-dasharray: 5 4; }
.chart .actions { fill: none; stroke: var(--accent); stroke-width: 2.5; }
.chart .base-band { fill: rgba(229, 83, 75, 0.12); }
.chart .actions-band { fill: rgba(76, 201, 164, 0.14); }
.chart .marker { stroke: rgba(255, 255, 255, 0.14); stroke-dasharray: 3 4; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); padding: 8px 4px 2px; }
.legend i { display: inline-block; width: 18px; height: 0; border-top-width: 2px; border-top-style: solid; margin-right: 6px; vertical-align: middle; }
.legend .l-history { border-color: var(--text); }
.legend .l-base { border-color: var(--bad); border-top-style: dashed; }
.legend .l-actions { border-color: var(--accent); }

.scenario-note { margin: 8px 2px 0; font-size: 12.5px; color: var(--muted); }
.scenario-note b { color: var(--text); font-weight: 600; }

.meta-line { margin-top: 10px; font-size: 11px; color: var(--muted); }

.degraded {
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(227, 179, 65, 0.35);
  background: rgba(227, 179, 65, 0.07);
  color: #e3c98c;
  font-size: 12px;
}

/* ---------- подвал ---------- */

.foot {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 7px 18px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  background: #0d1217;
}

.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}
.linklike:hover { text-decoration: underline; }

/* ---------- ящики ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(560px, 92vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  z-index: 21;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 40px rgba(0, 0, 0, 0.35);
}

.drawer header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer h2 { margin: 0; font-size: 13px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.drawer-body { overflow-y: auto; padding: 18px 20px 30px; }

.original-role { margin-bottom: 22px; }
.original-role h4 { margin: 0 0 8px; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-bottom: 10px; }
.answer-cell {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 5px 9px;
  background: #0b0f13;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.answer-cell span:last-child { font-family: var(--mono); color: var(--text); }

.original-text { font-size: 12.5px; line-height: 1.5; color: var(--text); margin: 6px 0 0; }
.original-label { font-size: 11px; color: var(--muted); margin-top: 10px; }
.original-time { font-size: 11px; color: var(--muted); margin-bottom: 10px; }

.log-row { padding: 9px 0; border-top: 1px solid var(--line); font-size: 12px; }
.log-row:first-child { border-top: 0; }
.log-head { display: flex; gap: 8px; align-items: center; font-family: var(--mono); font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.log-raw {
  margin: 6px 0 0;
  padding: 8px;
  background: #0b0f13;
  border: 1px solid var(--line);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 11px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 150px;
  overflow: auto;
}

/* ---------- тост ---------- */

.toast {
  position: fixed;
  right: 22px;
  bottom: 52px;
  z-index: 30;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid rgba(76, 201, 164, 0.4);
  background: #14211c;
  color: var(--text);
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

/* ---------- узкие экраны ---------- */

@media (max-width: 1100px) {
  body.dash { overflow: auto; height: auto; }
  .layout { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); max-height: 52vh; }
  .card { padding: 18px; }
  .kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-score { text-align: left; }
}

@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 10px; }
  .card-hero { grid-template-columns: 52px minmax(0, 1fr); }
  .hero-score { grid-column: 1 / -1; }
  .gap-row { grid-template-columns: 96px 1fr; }
  .gap-values { grid-column: 2; text-align: left; }
}

/* ---------- перекрытия базовых стилей ---------- */

/* Базовая таблица задаёт main отступы и ширину, а .card — рамку панели.
   В дашборде это отдельные области экрана, а не карточки контента. */
.dash .layout {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.dash .card {
  background: transparent;
  border: 0;
  border-radius: 0;
}

.dash .kpi-chip,
.dash .segmented button,
.dash .filters button,
.dash .linklike {
  font-weight: 500;
}

/* hidden должен побеждать display:flex у ящиков */
.dash .drawer[hidden],
.dash .scrim[hidden],
.dash .toast[hidden] {
  display: none !important;
}

/* Широкий экран: строки не должны растягиваться на полтора метра. */
@media (min-width: 1600px) {
  .dash .card > * { max-width: 1400px; }
}

/* Низкий экран: матрица прокручивается внутри, чтобы список и причины остались видны. */
@media (max-height: 840px) {
  .pulse .heatmap { max-height: 152px; overflow-y: auto; }
}
