/* Page compositions for the Analytical Atlas visual direction.
   Global primitives stay in app.css; this file only owns page-level layouts. */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.atlas-kicker {
  margin: 0 0 var(--sp-2);
  color: var(--copper, var(--warn));
  font: 600 var(--fs-xs)/1 var(--font-mono);
  letter-spacing: .14em;
  text-transform: uppercase;
}

.atlas-deck {
  max-width: 760px;
  color: var(--text-muted);
  font-size: var(--fs-md);
  line-height: 1.65;
}

.atlas-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-4);
  color: var(--text-muted);
  font: 500 var(--fs-sm)/1.4 var(--font-mono);
}

.atlas-rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-5) 0;
}

.atlas-section {
  border-top: 1px solid var(--border);
  padding-top: var(--sp-4);
}

.atlas-section__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.atlas-section__heading h2,
.atlas-section__heading h3 {
  margin: 0;
}

.atlas-index {
  color: var(--text-muted);
  font: 600 var(--fs-xs)/1 var(--font-mono);
  letter-spacing: .12em;
}

/* Auth — editorial split rather than a floating generic card. */
.atlas-auth {
  min-height: calc(100vh - 76px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, .8fr);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--primary) 5%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--primary) 5%, transparent) 1px, transparent 1px),
    var(--bg);
  background-size: 72px 72px;
}

.atlas-auth__visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 620px;
  padding: clamp(40px, 7vw, 96px);
  overflow: hidden;
  border-right: 1px solid var(--border);
}

.atlas-auth__visual::after {
  content: "";
  position: absolute;
  width: min(54vw, 720px);
  aspect-ratio: 1;
  right: -18%;
  bottom: -34%;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 50%;
  box-shadow:
    0 0 0 72px color-mix(in srgb, var(--primary) 4%, transparent),
    0 0 0 144px color-mix(in srgb, var(--primary) 3%, transparent);
  pointer-events: none;
}

.atlas-auth__brand {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-3);
  color: var(--text);
  font-weight: 650;
}

.atlas-auth__brand img {
  width: 38px;
  height: 38px;
}

.atlas-auth__statement {
  position: relative;
  z-index: 1;
  max-width: 700px;
}

.atlas-auth__statement h1 {
  max-width: 12ch;
  margin-bottom: var(--sp-4);
  font-size: clamp(40px, 6vw, 76px);
  font-weight: 560;
  letter-spacing: -.045em;
}

.atlas-auth__coordinates {
  position: relative;
  z-index: 1;
  color: var(--text-muted);
  font: 500 var(--fs-xs)/1.5 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.atlas-auth__panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(32px, 6vw, 80px);
  background: color-mix(in srgb, var(--surface-1) 92%, transparent);
}

.atlas-auth__form {
  width: min(100%, 430px);
}

.atlas-auth__form h2 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-2xl);
}

.atlas-auth__form form {
  margin-top: var(--sp-5);
}

.atlas-auth__form label {
  display: block;
  margin: var(--sp-4) 0 var(--sp-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.atlas-auth__form button {
  width: 100%;
  margin-top: var(--sp-5);
}

.atlas-auth__footnote {
  margin-top: var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.atlas-auth__footnote--center {
  text-align: center;
}

/* World map home. */
body:has(.map-home) {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.map-home {
  width: 100%;
  max-width: none;
  min-height: calc(100vh - 250px);
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.map-home__intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-5);
  padding: var(--sp-4) clamp(20px, 4vw, 56px);
  border-bottom: 1px solid var(--border);
  background: var(--surface-1);
}

.map-home__intro h1 {
  margin: 0;
  font-size: clamp(26px, 3.2vw, 46px);
  font-weight: 560;
  letter-spacing: -.035em;
}

.map-home__intro p {
  max-width: 500px;
  margin: 0;
  color: var(--text-muted);
}

.map-home__stage {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 55% 50%, color-mix(in srgb, var(--primary) 7%, transparent), transparent 48%),
    var(--bg);
}

.map-home__stage::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--text-muted) 7%, transparent) 1px, transparent 1px),
    linear-gradient(color-mix(in srgb, var(--text-muted) 7%, transparent) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: linear-gradient(to bottom, transparent, #000 20%, #000 80%, transparent);
}

#mapWrapper.map-home__stage {
  overflow: hidden;
}

#svgMap {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

#svgMap svg {
  width: 100%;
  height: 100%;
}

#svgMap svg path {
  transition: fill var(--dur-fast) var(--ease-out),
              stroke var(--dur-fast) var(--ease-out);
}

#svgMap svg path.hover {
  stroke: var(--primary);
  stroke-width: 1.5;
}

#countryLabel {
  position: absolute;
  z-index: 10;
  display: none;
  padding: var(--sp-2) var(--sp-3);
  pointer-events: none;
  white-space: pre;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
}

.map-home__sidebar {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  padding: var(--sp-5);
  background: var(--surface-1);
  border-left: 1px solid var(--border);
}

.map-home__sidebar h2 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-xl);
}

.map-home__count {
  margin: var(--sp-5) 0 var(--sp-1);
  color: var(--text);
  font: 600 var(--fs-2xl)/1 var(--font-mono);
}

.map-home__legend {
  display: grid;
  gap: var(--sp-2);
  margin: var(--sp-5) 0;
  font-size: var(--fs-sm);
}

.map-home__legend span {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.map-home__legend .swatch {
  width: 18px;
  height: 3px;
  background: var(--border);
}

.map-home__legend .swatch--ready {
  background: var(--map-ready, #3d806b);
}

.map-home__legend .swatch--progress {
  background: var(--map-progress, #b77a35);
}

/* БФ-16: чипы needs_attention в Active coverage обведены янтарным пунктиром
   (#reviewList span[data-status="needs_attention"] ниже), а легенда этого
   статуса не объясняла. Тот же --map-attention и тот же пунктир, чтобы
   образец читался как ссылка на выделение, а не как ещё один цвет.
   БФ-38: значение --map-attention сменилось с красного (--danger) на
   спокойный янтарь (--warn) -- этот статус больше не значит "сломано", у
   страны есть полноценное досье, просто замечание к данным. */
.map-home__legend .swatch--attention {
  height: 0;
  border-top: 1px dashed var(--map-attention, #93671d);
}

/* БФ-38: единственный красный образец в легенде -- реально сломано.
   Ровно тот цвет, которым раньше (по ошибке) красилась needs_attention --
   владелец 19.08: красный должен значить "сломалось", а не "есть
   замечания". Только под user_sees_map_severity в index.html. */
.map-home__legend .swatch--broken {
  background: var(--map-broken, #a33f38);
}

.map-home__legend .swatch--idle {
  background: var(--border);
}

.map-home__review-label {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font: 600 var(--fs-xs)/1 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

#reviewList {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

#reviewList span {
  min-width: 42px;
  padding: 5px var(--sp-2);
  cursor: pointer;
  color: var(--text);
  background: transparent !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: 600 var(--fs-xs)/1 var(--font-mono);
  text-align: center;
}

#reviewList span[data-status="initialized"] {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
}

#reviewList span[data-status="in_progress"] {
  border-color: color-mix(in srgb, var(--warn) 60%, var(--border));
}

/* Ц1 Ц-D1: dashed outline, precedent admin_init.html's label.needs_attention
   (border: 2px dashed var(--danger)) -- distinct from the solid borders
   above, same "needs a look, not a blind retry" signal. БФ-38: colour is
   now a calm amber (--map-attention = --warn), not --danger red -- this
   chip only ever appears for operator+ on a country that HAS a dossier
   (see atlas.py::index_view), so it must not read as "broken". */
#reviewList span[data-status="needs_attention"] {
  border: 1px dashed var(--map-attention, #93671d);
  color: var(--map-attention, #93671d);
}

/* БФ-38: solid border, same red as the map fill below -- this chip means
   the country is genuinely broken (failed init task, or zero institutions
   after a completed run), operator+ only. */
#reviewList span[data-status="broken"] {
  border: 1px solid var(--map-broken, #a33f38);
  color: var(--map-broken, #a33f38);
}

/* Шаг D T-15: in-place call-to-action for a not-yet-started country --
   replaces navigating to a dead-end page. */
.map-home__cta {
  margin-top: var(--sp-5);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.map-home__cta-title {
  margin-bottom: var(--sp-1);
  font: 600 var(--fs-sm)/1.3 var(--font-mono);
}

.map-home__cta button {
  margin-top: var(--sp-2);
}

.initialized {
  fill: var(--map-ready, #3d806b) !important;
}

.in-progress {
  fill: var(--map-progress, #b77a35) !important;
}

/* Ц1 Ц-D1: third map status -- init ran to completion but needs an
   operator look (missing core institutions, or a key institution with no
   decision-makers). var()-with-fallback like the two above -- --map-ready/
   --map-progress/--map-attention are none of them declared in :root, they
   exist only as this fallback pattern.

   БФ-38: this status is now only ever sent to operator+ for a country that
   HAS institutions on file (atlas.py::index_view resolves needs_attention
   with zero institutions into "broken" instead -- see .broken below). The
   dossier is real, so the fill stays the normal "initialized" green; a
   dashed amber outline on top is the "есть замечания" signal, same visual
   grammar as the Active coverage chips (#reviewList span[data-status=
   "needs_attention"] above) instead of a second solid colour. */
.needs-attention {
  fill: var(--map-ready, #3d806b) !important;
  stroke: var(--map-attention, #93671d);
  stroke-width: 2px;
  stroke-dasharray: 4 3;
}

/* БФ-38: the only red fill on the map -- "сломалось", not "есть
   замечания" (владелец 19.08). Reuses the exact colour needs-attention used
   to have (it was the same --danger red under a misleading name) -- see
   status.py::InitStatus.BROKEN and atlas.py::index_view for what counts:
   a FAILED (re)init task, or zero institutions after a completed run.
   operator+ only -- viewer/chatter's countryData never contains "broken". */
.broken {
  fill: var(--map-broken, #a33f38) !important;
}

/* Scenario index and composer. */
.scenario-page {
  width: min(100%, 1320px);
  max-width: none;
}

.scenario-intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: var(--sp-6);
  align-items: end;
  margin-bottom: var(--sp-6);
}

.scenario-intro h1 {
  max-width: 14ch;
  margin-bottom: var(--sp-3);
  font-size: clamp(36px, 5vw, 62px);
  font-weight: 560;
  letter-spacing: -.04em;
}

.scenario-intro__note {
  padding-left: var(--sp-4);
  border-left: 2px solid var(--copper, var(--warn));
  color: var(--text-muted);
  line-height: 1.6;
}

.scenario-compose {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.scenario-compose__primary,
.scenario-compose__settings {
  padding: clamp(20px, 3vw, 36px);
}

.scenario-compose__settings {
  border-left: 1px solid var(--border);
  background: var(--surface-2);
}

.scenario-compose h2 {
  font-size: var(--fs-xl);
}

.scenario-field {
  display: block;
  margin-top: var(--sp-4);
}

.scenario-field > span:first-child {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.scenario-field small {
  font-weight: 400;
  color: var(--text-muted);
}

.scenario-compose textarea {
  min-height: 130px;
  resize: vertical;
}

/* Шаг D T-06: checkbox-chip country picker, replacing <select multiple>. */
.country-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  max-height: 220px;
  overflow-y: auto;
  padding: var(--sp-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-1, var(--bg-card));
}

.country-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1, 4px);
  padding: 4px var(--sp-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  cursor: pointer;
  user-select: none;
}

.country-chip input {
  width: auto;
  margin: 0;
}

.country-chip:has(input:checked) {
  background: var(--accent, var(--ok));
  border-color: var(--accent, var(--ok));
  color: #fff;
}

.country-chip:focus-within {
  outline: 2px solid var(--accent, var(--ok));
  outline-offset: 2px;
}

.scenario-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

.scenario-toggle {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: var(--sp-2);
  align-items: start;
  margin-top: var(--sp-4);
  color: var(--text);
  font-size: var(--fs-sm);
  line-height: 1.45;
}

.scenario-toggle input {
  width: auto;
  margin-top: 2px;
}

.scenario-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
}

.scenario-actions button {
  margin: 0;
}

.scenario-help {
  margin-top: var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.run-index {
  margin-top: var(--sp-6);
}

.run-index__table {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

.run-index tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}

.run-index tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

/* Public demo — read-only scenario brief. */
.demo-brief {
  max-width: 1380px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 56px);
}

.demo-hero {
  position: relative;
  overflow: hidden;
  min-height: 300px;
  padding: clamp(28px, 5vw, 64px);
  color: var(--text);
  background:
    radial-gradient(circle at 82% 18%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 30%),
    var(--surface-1);
  border: 1px solid var(--border);
}

.demo-hero::after {
  content: "";
  position: absolute;
  right: -120px;
  bottom: -240px;
  width: 520px;
  height: 520px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent);
  border-radius: 50%;
  box-shadow: 0 0 0 64px color-mix(in srgb, var(--primary) 5%, transparent);
}

.demo-hero__content {
  position: relative;
  z-index: 1;
  max-width: 850px;
}

.demo-hero h1 {
  max-width: 18ch;
  margin-bottom: var(--sp-4);
  font-size: clamp(36px, 5vw, 68px);
  font-weight: 560;
  letter-spacing: -.045em;
}

.demo-disclosure {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sp-3);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.demo-route {
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  margin: var(--sp-6) 0;
  padding: var(--sp-4) 0;
}

.demo-route__node {
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 50%;
  font: 650 var(--fs-sm)/1 var(--font-mono);
}

.demo-route__line {
  flex: 1 0 54px;
  height: 1px;
  background:
    linear-gradient(90deg, var(--border), var(--copper, var(--warn)), var(--border));
}

.demo-overview {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: var(--sp-6);
  align-items: start;
}

.demo-panel {
  min-width: 0;
  border-top: 2px solid var(--text);
  padding-top: var(--sp-4);
}

.demo-panel--accent {
  border-top-color: var(--copper, var(--warn));
}

.demo-table-wrap {
  max-height: 560px;
  overflow: auto;
}

.demo-event-ledger {
  display: grid;
  gap: 0;
}

.demo-event {
  position: relative;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}

.demo-event__tick {
  color: var(--copper, var(--warn));
  font: 600 var(--fs-xs)/1.5 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.demo-event__body {
  line-height: 1.55;
}

/* Classic run detail. */
.run-page {
  width: min(100%, 1420px);
  max-width: none;
}

.run-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--sp-5);
  margin-bottom: var(--sp-4);
  padding: var(--sp-5);
  background: var(--surface-1);
  border-left: 3px solid var(--copper, var(--warn));
}

.run-brief__copy p {
  max-width: 920px;
  margin: var(--sp-2) 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.run-brief__actions {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.run-brief__actions button {
  margin: 0;
}

.run-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
}

.run-stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: var(--sp-5);
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
}

.run-stat-row .metric {
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

/* ТРЕК Н-10 Шаг E4.3 (Р-E12): "Deferred checks" table -- same bottom-gap
   idiom as .run-participants below, just margin-bottom instead of -top
   because this section sits BEFORE .run-stat-row rather than after a
   bottom-margin-less sibling. */
.run-checks {
  margin-bottom: var(--sp-5);
}

.run-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, .75fr);
  gap: var(--sp-4);
  align-items: start;
}

.run-data-panel {
  min-width: 0;
  background: var(--surface-1);
  border-top: 2px solid var(--text);
  padding: var(--sp-4);
}

.run-data-panel--relations {
  border-top-color: var(--copper, var(--warn));
}

.run-table-window {
  max-height: 520px;
  overflow: auto;
}

.run-table-window th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-1);
}

.run-operations {
  margin-top: var(--sp-5);
  border-top: 1px solid var(--border);
  padding-top: var(--sp-5);
}

.run-operations__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
  gap: var(--sp-4);
}

.run-operation {
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.run-operation h3 {
  margin-bottom: var(--sp-2);
}

.run-operation--span {
  grid-column: 1 / -1;
}

.run-operation__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: end;
  margin-top: var(--sp-3);
}

.run-operation__row > * {
  margin: 0;
}

.run-operation__row input,
.run-operation__row select {
  width: auto;
  min-width: 120px;
  flex: 1 1 150px;
}

.run-timeline {
  margin-top: var(--sp-6);
  border-top: 2px solid var(--text);
  padding-top: var(--sp-4);
}

.run-timeline #feed {
  display: grid;
}

.run-timeline .ev {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: var(--sp-4);
  margin: 0;
  padding: var(--sp-4) 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
}

.run-timeline .ev__rail {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--sp-2);
  align-items: start;
  color: var(--text-muted);
}

.run-timeline .ev__rail::after {
  content: "";
  position: absolute;
  top: 26px;
  bottom: calc(var(--sp-4) * -1);
  left: 41px;
  width: 1px;
  background: var(--border);
}

.run-timeline .ev:last-child .ev__rail::after {
  display: none;
}

.run-timeline .ev__tick {
  font: 620 var(--fs-xs)/1.5 var(--font-mono);
  letter-spacing: .04em;
}

.run-timeline .ev__glyph {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font: 600 12px/1 var(--font-mono);
}

.run-timeline .summary .ev__glyph {
  border-color: var(--primary);
  color: var(--primary);
}

.run-timeline .injection .ev__glyph {
  border-color: var(--copper, var(--warn));
  color: var(--copper, var(--warn));
}

.run-timeline .ev__content {
  min-width: 0;
}

.run-timeline .ev__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: baseline;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.run-timeline .ev__meta strong {
  color: var(--text);
}

.run-timeline .ev__meta .vis {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.run-timeline .ev__result {
  max-width: 920px;
  margin-top: 5px;
  color: var(--text);
  line-height: 1.55;
}

.run-participants {
  margin-top: var(--sp-6);
}

/* Causal audit record. */
#traceModal {
  position: fixed;
  top: 6%;
  left: 50%;
  z-index: var(--z-modal, 1000);
  display: none;
  width: min(680px, calc(100% - 32px));
  max-height: 86vh;
  padding: clamp(20px, 3vw, 32px);
  overflow-y: auto;
  color: var(--text);
  background:
    linear-gradient(to right, var(--atlas-grid) 1px, transparent 1px),
    var(--surface-2);
  background-size: 48px 48px;
  border: 1px solid var(--border);
  border-top: 3px solid var(--copper, var(--warn));
  border-radius: var(--radius);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-base);
  transform: translateX(-50%);
}

#traceModal h4 {
  margin: var(--sp-5) 0 var(--sp-2);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
}

#traceModal .close {
  float: right;
  width: 34px;
  min-height: 34px;
  margin: 0;
  padding: 0;
  border-color: var(--border);
  background: transparent;
  color: var(--text);
  font-size: 20px;
}

#traceModal ul {
  margin: var(--sp-2) 0;
  padding-left: 20px;
}

#traceModal .kv {
  color: var(--text-muted);
}

#traceModal .qbadge {
  margin-left: 4px;
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 2px;
  cursor: help;
  font: 600 var(--fs-xs)/1.2 var(--font-mono);
}

#traceModal .q-A,
#traceModal .q-B {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--border));
}

#traceModal .q-C {
  border-color: color-mix(in srgb, var(--warn) 55%, var(--border));
}

#traceModal .q-D,
#traceModal .q-none {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--border));
}

#traceModal .q-expert {
  border-color: var(--text-muted);
}

#traceModal details summary {
  cursor: pointer;
}

#traceModal .freshness-banner {
  margin: var(--sp-3) 0;
  padding: var(--sp-3);
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface-1));
  border-left: 2px solid var(--warn);
  font-size: var(--fs-sm);
}

/* ТРЕК Н-10 Шаг A (Р-7): as-of honesty плашка on simulation.html -- same
   warn-toned shape as .freshness-banner above, not scoped to #traceModal. */
.asof-banner {
  margin: var(--sp-3) 0;
  padding: var(--sp-3);
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--surface-1));
  border-left: 2px solid var(--warn);
  font-size: var(--fs-sm);
}

/* Full-height analytical workspaces: map, graph and timeline. */
body.workspace-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.workspace-shell > .site-footer {
  display: none;
}

.workspace-header {
  flex: none;
  border-radius: 0;
}

.workspace-header h1 {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  font-family: var(--font-ui);
  font-size: var(--fs-lg);
  font-weight: 620;
  letter-spacing: -.015em;
}

.workspace-header__kind {
  color: var(--text-muted);
  font: 620 var(--fs-xs)/1 var(--font-mono);
  letter-spacing: .1em;
  text-transform: uppercase;
}

.workspace-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  align-items: center;
  margin-left: auto;
}

.workspace-control {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  color: var(--nav-ink);
  font-size: var(--fs-xs);
}

.workspace-control select {
  width: auto;
  min-height: 32px;
  margin: 0;
  padding: 4px 28px 4px 8px;
}

.workspace-toggle {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 32px;
  margin: 0;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--nav-ink);
  font-size: var(--fs-xs);
}

.workspace-toggle input {
  width: auto;
  margin: 0;
}

.workspace-scale {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text-muted);
  font: 600 var(--fs-xs)/1 var(--font-mono);
}

.workspace-scale__bar {
  width: 76px;
  height: 5px;
  background: linear-gradient(90deg, #38474a, #557987, #d0a56a);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.workspace-canvas {
  min-height: 0;
  flex: 1;
  background:
    linear-gradient(to right, var(--atlas-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--atlas-grid) 1px, transparent 1px),
    var(--bg);
  background-size: 64px 64px;
}

.workspace-fallback {
  display: none;
  flex: 1;
  place-content: center;
  padding: var(--sp-7);
  text-align: center;
}

.workspace-legend {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  gap: var(--sp-4);
  align-items: center;
  min-height: 42px;
  padding: var(--sp-2) var(--sp-5);
  color: var(--text-muted);
  background: var(--surface-1);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
}

.workspace-legend__item {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.workspace-legend__swatch {
  display: inline-block;
  width: 20px;
  height: 3px;
  background: var(--border);
}

.workspace-legend__swatch--positive { background: #78adbf; }
.workspace-legend__swatch--negative { background: #d28a5b; }
.workspace-legend__swatch--treaty {
  height: 0;
  border-top: 2px dashed #9aa49f;
  background: transparent;
}
.workspace-legend__swatch--economic { background: #d1a24f; }

.workspace-shell .maplibregl-popup-content {
  padding: var(--sp-3);
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
}

.workspace-shell .maplibregl-popup-tip {
  border-top-color: var(--surface-2);
}

.workspace-timeline {
  min-height: 0;
  flex: 1;
  background: var(--surface-2);
}

.workspace-timeline .vis-timeline {
  border-color: var(--border);
  color: var(--text);
}

.workspace-timeline .vis-panel.vis-bottom,
.workspace-timeline .vis-labelset .vis-label,
.workspace-timeline .vis-time-axis .vis-text {
  color: var(--text-muted);
  border-color: var(--border);
}

.workspace-timeline .vis-grid.vis-minor,
.workspace-timeline .vis-labelset .vis-label {
  border-color: color-mix(in srgb, var(--border) 72%, transparent);
}

.workspace-timeline .vis-item {
  color: var(--text);
  background: var(--surface-1);
  border-color: var(--primary);
  border-radius: 2px;
}

.workspace-timeline .vis-item.vis-dot {
  border-color: var(--primary);
}

.workspace-timeline .vis-item.vis-selected {
  color: var(--text);
  background: var(--copper-soft);
  border-color: var(--copper);
}

/* Empty decision-maker dossier. */
.profile-unavailable {
  display: grid;
  flex: 1;
  place-items: center;
  min-height: calc(100vh - 180px);
}

.profile-unavailable__brief {
  width: min(100%, 650px);
  padding: clamp(28px, 6vw, 64px);
  background: var(--surface-1);
  border-top: 3px solid var(--copper);
}

.profile-unavailable__mark {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: var(--sp-5);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 50%;
}

.profile-unavailable__mark .icon {
  width: 22px;
  height: 22px;
}

/* Country dossier. */
.country-dossier {
  display: grid;
  grid-template-areas:
    "identity identity"
    "report institutions";
  grid-template-columns: minmax(0, .9fr) minmax(560px, 1.1fr);
  width: min(100%, 1500px);
  max-width: 1500px;
  min-height: calc(100vh - 112px);
  padding: 0;
  gap: 1px;
  border-right: 1px solid var(--border);
  border-left: 1px solid var(--border);
  background: var(--border);
}

.country-dossier__identity {
  grid-area: identity;
  min-width: 0;
  padding: clamp(24px, 3vw, 44px);
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--primary) 5%, transparent) 1px, transparent 1px),
    var(--surface-1);
  background-size: 64px 64px;
}

.country-dossier__masthead {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(300px, .62fr);
  align-items: center;
  gap: clamp(var(--sp-4), 2.4vw, var(--sp-6));
}

.country-dossier__heading {
  min-width: 0;
}

.country-dossier__code {
  display: inline-grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 50%;
  font: 650 var(--fs-xl)/1 var(--font-mono);
}

.country-dossier__title {
  margin-bottom: var(--sp-3);
  font-size: clamp(42px, 5vw, 64px);
  font-weight: 560;
  letter-spacing: -.045em;
  overflow-wrap: anywhere;
}

/* Владелец 2026-08-11: full (re)init progress bar -- shared between
   country_uninitialized.html (fresh full_init) and country.html (full
   reinit of an already-initialized country). Amber like the atlas map's
   .in-progress fill (--map-progress); each page's own poll of /status/
   {code} toggles the `hidden` attribute and fills in the label/width. */
.init-progress {
  margin: var(--sp-3) 0;
}

.init-progress__bar {
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.init-progress__fill {
  height: 100%;
  background: var(--map-progress, var(--warn));
  transition: width .4s ease;
}

.init-progress__label {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-top: var(--sp-1);
  color: var(--copper, var(--warn));
  font: 600 var(--fs-xs)/1.3 var(--font-mono);
  letter-spacing: .04em;
  text-transform: uppercase;
}

.country-dossier__facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 76%, transparent);
}

.country-dossier__fact {
  min-width: 0;
  padding: var(--sp-3) var(--sp-4);
}

.country-dossier__fact:nth-child(even) {
  padding-left: var(--sp-4);
  border-left: 1px solid var(--border);
}

.country-dossier__fact span {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.country-dossier__fact strong {
  display: block;
  margin-top: var(--sp-1);
  font: 600 var(--fs-md)/1.4 var(--font-mono);
  overflow-wrap: anywhere;
}

.country-dossier .init-progress {
  max-width: 760px;
  margin-top: var(--sp-5);
}

.country-dossier .admin-alert.country-dossier__alert {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--sp-3);
  max-width: 940px;
  margin: var(--sp-4) 0 0;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--danger) 42%, var(--border));
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 11%, var(--surface-1));
  color: var(--text);
}

.country-dossier__alert > svg {
  margin-top: 2px;
  color: var(--danger);
}

.country-dossier__alert strong {
  display: block;
  color: var(--text);
  font-size: var(--fs-sm);
}

.country-dossier__alert p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.country-dossier__contents {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.country-dossier__contents a {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: var(--sp-2);
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface-2) 72%, transparent);
  color: var(--text);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

.country-dossier__contents a:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface-2));
  text-decoration: none;
}

.country-dossier__contents a > span,
.country-dossier__section-index {
  color: var(--copper);
  font: 650 var(--fs-xs)/1 var(--font-mono);
  letter-spacing: .08em;
}

.country-dossier__contents small {
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  padding-inline: 5px;
  place-items: center;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--text-muted);
  font: 600 10px/1 var(--font-mono);
}

.country-dossier__report-panel,
.country-dossier__institutions {
  min-width: 0;
  padding: clamp(24px, 3vw, 44px);
  background: var(--bg);
  scroll-margin-top: 78px;
}

.country-dossier__report-panel {
  grid-area: report;
}

.country-dossier__section-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--border);
}

.country-dossier__section-heading .atlas-kicker {
  margin-bottom: var(--sp-1);
}

.country-dossier__section-heading h2 {
  margin: 0;
  font-size: clamp(29px, 3vw, 42px);
}

.country-dossier__section-heading > .atlas-meta,
.country-dossier__record-count {
  align-self: center;
  white-space: nowrap;
}

.country-dossier__report {
  min-width: 0;
  max-width: 78ch;
  color: var(--text);
  font-size: var(--fs-md);
  line-height: 1.74;
  overflow-wrap: break-word;
}

.country-dossier__report > :first-child {
  margin-top: 0;
}

.country-dossier__report h1 {
  max-width: 24ch;
  margin: 0 0 var(--sp-6);
  font-size: clamp(30px, 2.6vw, 42px);
  font-weight: 540;
  line-height: 1.06;
  letter-spacing: -.038em;
  text-wrap: pretty;
  overflow-wrap: anywhere;
}

.country-dossier__report h2,
.country-dossier__report h3 {
  overflow-wrap: anywhere;
}

.country-dossier__report h2 {
  margin-top: var(--sp-7);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.country-dossier__report h3 {
  margin-top: var(--sp-5);
}

.country-dossier__report p,
.country-dossier__report li,
.country-dossier__report a {
  overflow-wrap: anywhere;
}

.country-dossier__report ul,
.country-dossier__report ol {
  padding-left: var(--sp-5);
}

.country-dossier__report blockquote {
  margin: var(--sp-5) 0;
  padding: var(--sp-3) var(--sp-4);
  border-left: 2px solid var(--copper);
  background: var(--surface-1);
  color: var(--text-muted);
}

.country-dossier__report pre {
  max-width: 100%;
  padding: var(--sp-4);
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.country-dossier__report table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
}

.country-dossier__institutions {
  grid-area: institutions;
  overflow: visible;
}

.country-discovery {
  margin: calc(-1 * var(--sp-2)) 0 var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
}

.country-discovery summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 38px;
  padding: 7px var(--sp-3);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
}

.country-discovery summary .pill {
  margin-left: auto;
}

.country-discovery p {
  margin: 0;
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.country-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-4) 0;
}

.country-admin-actions form,
.country-admin-actions button {
  margin: 0;
}

.country-admin-actions button.danger {
  border-color: color-mix(in srgb, var(--danger) 72%, #000000);
  background: color-mix(in srgb, var(--danger) 72%, #000000);
}

.country-add {
  margin: var(--sp-4) 0 var(--sp-5);
  padding: var(--sp-3);
  background: var(--surface-1);
  border: 1px solid var(--border);
}

.country-add form {
  display: flex;
  gap: var(--sp-2);
}

.country-add input {
  flex: 1;
  min-width: 0;
}

.country-dossier__institutions .table {
  table-layout: fixed;
}

.country-dossier__institutions .table-scroll {
  overflow: visible;
}

.country-dossier__institutions .table-scroll th {
  top: 62px;
}

.country-dossier__institutions .table th,
.country-dossier__institutions .table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.country-dossier__institutions .table td:first-child strong {
  font-weight: 650;
}

.country-dossier__col-name { width: 29%; }
.country-dossier__col-type { width: 20%; }
.country-dossier__col-ownership { width: 16%; }
.country-dossier__col-description { width: 35%; }

@media (max-width: 1180px) {
  .country-dossier {
    grid-template-areas:
      "identity"
      "report"
      "institutions";
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
    border-right: 0;
    border-left: 0;
  }

  .country-dossier__report {
    max-width: 82ch;
  }
}

@media (max-width: 820px) {
  .country-dossier__masthead {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .country-dossier__facts {
    grid-column: 1 / -1;
  }

  .country-dossier__report-panel,
  .country-dossier__institutions {
    scroll-margin-top: 112px;
  }

  .country-dossier__institutions .table-scroll th {
    top: 89px;
  }
}

@media (max-width: 720px) {
  .country-dossier__identity,
  .country-dossier__report-panel,
  .country-dossier__institutions {
    padding: var(--sp-5) var(--sp-4);
  }

  .country-dossier__section-heading {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .country-dossier__section-heading > .atlas-meta,
  .country-dossier__record-count {
    grid-column: 2;
    justify-self: start;
  }

  .country-dossier__institutions .table-scroll {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .country-dossier__institutions table.table {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    border: 0;
    white-space: normal;
  }

  .country-dossier__institutions .table colgroup {
    display: none;
  }

  .country-dossier__institutions .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .country-dossier__institutions .table tbody {
    display: grid;
    gap: var(--sp-3);
  }

  .country-dossier__institutions .table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--border);
    border-top: 2px solid color-mix(in srgb, var(--primary) 62%, var(--border));
    border-radius: var(--radius-sm);
    background: var(--surface-1);
  }

  .country-dossier__institutions .table td {
    display: grid;
    grid-template-columns: minmax(76px, .4fr) minmax(0, 1fr);
    gap: var(--sp-2);
    padding: 9px var(--sp-3);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: normal;
  }

  .country-dossier__institutions .table td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font: 650 9px/1.5 var(--font-ui);
    letter-spacing: .08em;
    text-transform: uppercase;
  }

  .country-dossier__institutions .table td:first-child,
  .country-dossier__institutions .table td:last-child,
  .country-dossier__institutions .table td[colspan] {
    grid-column: 1 / -1;
    border-right: 0;
  }

  .country-dossier__institutions .table td:nth-child(3) {
    border-right: 0;
  }

  .country-dossier__institutions .table td:last-child {
    border-bottom: 0;
  }

  .country-dossier__institutions .table tr:last-child td:not(:last-child) {
    border-bottom-color: var(--border);
  }

  .country-dossier__institutions .table td[colspan]::before {
    content: none;
  }
}

@media (max-width: 520px) {
  .country-dossier__masthead {
    grid-template-columns: 1fr;
  }

  .country-dossier__code {
    width: 60px;
    height: 60px;
  }

  .country-dossier__title {
    font-size: clamp(38px, 13vw, 52px);
  }

  .country-dossier__contents {
    display: grid;
    grid-template-columns: 1fr;
  }

  .country-dossier__contents a {
    grid-template-columns: auto minmax(0, 1fr) auto;
  }

  .country-dossier__institutions .table tr {
    grid-template-columns: minmax(0, 1fr);
  }

  .country-dossier__institutions .table td {
    grid-column: 1;
    border-right: 0;
  }

  .country-admin-actions form,
  .country-admin-actions button,
  .country-add button {
    width: 100%;
  }

  .country-add button {
    margin: 0;
  }
}

/* Шаг E E3: institution.html's add-dm section reuses .country-add's card
   look but lays out two independent actions (manual form + auto-extract
   button) side by side instead of one full-width form. */
.dm-add {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  justify-content: space-between;
}

.dm-add-manual {
  flex: 1;
  min-width: 260px;
}

.country-uninitialized {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 120px);
  padding: var(--sp-5);
}

.country-uninitialized__brief {
  width: min(100%, 720px);
  padding: clamp(28px, 5vw, 56px);
  text-align: left;
  background: var(--surface-1);
  border-top: 3px solid var(--copper, var(--warn));
}

.country-uninitialized__mark {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin-bottom: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--copper, var(--warn));
}

.country-uninitialized .error-banner {
  margin: var(--sp-5) 0;
  padding: var(--sp-4);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 8%, var(--surface-1));
  border: 1px solid color-mix(in srgb, var(--danger) 55%, var(--border));
  word-break: break-word;
}

/* About and admin overview. */
.about-brief {
  max-width: 900px;
  margin: var(--sp-6) auto;
  padding: clamp(24px, 4vw, 56px);
  background: var(--surface-1);
  border-top: 3px solid var(--copper, var(--warn));
}

.about-brief h1 {
  max-width: 16ch;
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -.035em;
}

.about-brief h2,
.about-brief h3 {
  margin-top: var(--sp-6);
}

.about-brief p,
.about-brief li {
  line-height: 1.7;
}

.about-brief li {
  margin: var(--sp-2) 0;
}

.admin-overview__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--sp-5);
  margin-bottom: var(--sp-6);
}

.admin-overview__header h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 52px);
  letter-spacing: -.035em;
}

.admin-alert {
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  color: var(--danger-ink, #fff);
  background: var(--danger);
  border-left: 3px solid currentColor;
}

.admin-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--border);
  border: 1px solid var(--border);
}

.admin-metrics .metric {
  min-height: 116px;
  margin: 0;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.admin-metrics .metric .v {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-variant-numeric: tabular-nums;
}

.admin-ledgers {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-4);
  margin-top: var(--sp-6);
}

.admin-ledger {
  padding-top: var(--sp-4);
  border-top: 2px solid var(--text);
}

.admin-ledger code {
  display: inline-block;
  margin: var(--sp-1) var(--sp-1) var(--sp-1) 0;
  padding: 2px var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 2px;
}

@media (max-width: 1100px) {
  .atlas-auth {
    grid-template-columns: 1fr 420px;
  }

  .map-home {
    grid-template-columns: minmax(0, 1fr) 280px;
  }

  .scenario-compose,
  .demo-overview,
  .run-operations__grid {
    grid-template-columns: 1fr;
  }

  .scenario-compose__settings {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .admin-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .atlas-auth {
    display: block;
  }

  .atlas-auth__visual {
    min-height: 330px;
    padding: var(--sp-6) var(--sp-5);
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .atlas-auth__statement h1 {
    font-size: clamp(36px, 11vw, 58px);
  }

  .map-home__intro {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-home {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 62vh) auto;
    overflow: auto;
  }

  .map-home__sidebar {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .scenario-intro,
  .run-analysis-grid,
  .country-dossier {
    grid-template-columns: 1fr;
  }

  .country-dossier__identity {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .run-brief {
    grid-template-columns: 1fr;
  }

  .run-brief__actions {
    justify-content: flex-start;
  }

  .run-stat-row {
    grid-template-columns: 1fr 1fr;
  }

  .admin-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-ledgers {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .atlas-auth__panel,
  .demo-brief {
    padding: var(--sp-4);
  }

  .scenario-settings-grid,
  .run-stat-row,
  .country-dossier__facts,
  .admin-metrics {
    grid-template-columns: 1fr;
  }

  .country-dossier__fact:nth-child(even) {
    padding-left: var(--sp-4);
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .country-add form,
  .scenario-actions,
  .run-operation__row {
    align-items: stretch;
    flex-direction: column;
  }

  .run-operation__row input,
  .run-operation__row select {
    width: 100%;
  }

  .run-context-header {
    justify-content: center;
  }

  .run-context-header h1 {
    width: 100%;
    justify-content: center;
    padding-inline: 72px;
    text-align: center;
  }

  .run-context-header .page-actions {
    justify-content: center;
    flex-wrap: wrap;
    overflow: visible;
  }
}

/* Н-9 Шаг 1 (Р-2): "How it works" section -- sidebar table of contents +
   article, reusing .about-brief's typography for the content column. */
.hiw-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--sp-6);
  max-width: 1100px;
  margin: var(--sp-6) auto;
  padding: 0 var(--sp-4);
  align-items: start;
}

.hiw-toc {
  position: sticky;
  top: var(--sp-5);
}

.hiw-toc__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  border-left: 2px solid var(--border);
}

.hiw-toc__list a {
  display: block;
  padding: var(--sp-1, 4px) var(--sp-4);
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--text-muted);
  text-decoration: none;
  font-size: var(--fs-sm);
}

.hiw-toc__list a:hover {
  color: var(--text);
}

.hiw-toc__list a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
  border-left-color: var(--copper, var(--warn));
}

.hiw-article {
  margin: 0;
  max-width: none;
}

.hiw-article pre.mermaid {
  margin: var(--sp-5) 0;
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow-x: auto;
}

.hiw-toc__overview {
  display: block;
  margin-bottom: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  text-decoration: none;
}

.hiw-toc__overview:hover,
.hiw-toc__overview[aria-current="page"] {
  border-color: color-mix(in srgb, var(--copper) 54%, var(--border));
  color: var(--text);
  text-decoration: none;
}

.hiw-progress {
  height: 2px;
  margin-top: var(--sp-4);
  overflow: hidden;
  background: var(--border);
}

.hiw-progress > span {
  display: block;
  width: var(--hiw-progress, 0%);
  height: 100%;
  background: var(--copper);
  transition: width var(--dur-med) var(--ease-out);
}

.hiw-honesty-strip {
  display: grid;
  grid-template-columns: minmax(180px, .56fr) minmax(0, 1fr);
  gap: var(--sp-4);
  margin: var(--sp-5) 0 var(--sp-7);
  padding: var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--copper) 42%, var(--border));
  border-left: 3px solid var(--copper);
  background: color-mix(in srgb, var(--copper) 7%, var(--surface-1));
  color: var(--text-muted);
  line-height: 1.55;
}

.hiw-honesty-strip strong { color: var(--text); }

.hiw-overview__map { margin-block: var(--sp-7); }

.hiw-section-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, .54fr);
  gap: var(--sp-5);
  align-items: end;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.hiw-section-heading h2 { margin: 0; }
.hiw-section-heading > p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.hiw-lens-picker {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin: var(--sp-5) 0 var(--sp-3);
}

.hiw-lens-button {
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-1);
  color: var(--text-muted);
  font: 600 var(--fs-sm)/1 var(--font-ui);
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}

.hiw-lens-button:hover,
.hiw-lens-button[aria-pressed="true"] {
  border-color: var(--copper);
  background: color-mix(in srgb, var(--copper) 10%, var(--surface-1));
  color: var(--text);
}

.hiw-lens-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
}

.hiw-lens-panel {
  min-width: 0;
  padding: var(--sp-4);
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.hiw-lens-panel[hidden] { display: none; }
.hiw-lens-panel h3 { margin-top: 0; }
.hiw-lens-panel p:last-child { margin-bottom: 0; }

.hiw-chapter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 var(--sp-7);
  padding: 1px;
  list-style: none;
  background: var(--border);
}

.hiw-chapter-grid li { min-width: 0; }
.hiw-chapter-grid li:last-child:nth-child(odd) { grid-column: 1 / -1; }

.hiw-chapter-grid a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: var(--sp-3);
  align-items: center;
  min-height: 76px;
  padding: var(--sp-4);
  background: var(--surface-1);
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.hiw-chapter-grid a:hover {
  background: color-mix(in srgb, var(--primary) 7%, var(--surface-1));
  text-decoration: none;
}

.hiw-chapter-grid__index {
  color: var(--copper);
  font-size: var(--fs-xs);
  letter-spacing: .08em;
}

.hiw-chapter-grid__copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.hiw-chapter-grid__copy small {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 450;
  line-height: 1.45;
}

.hiw-chapter-grid a > span:last-child {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.hiw-next-actions {
  margin: var(--sp-7) 0;
  padding: clamp(var(--sp-4), 4vw, var(--sp-6));
  border: 1px solid var(--border);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary) 8%, transparent), transparent 55%),
    var(--surface-1);
}

.hiw-next-actions h2 { max-width: 22ch; }
.hiw-next-actions > div {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
}

.hiw-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-7);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
}

.hiw-pager a {
  display: grid;
  gap: 3px;
  min-height: 70px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text);
  text-decoration: none;
}

.hiw-pager a:hover {
  border-color: var(--primary);
  text-decoration: none;
}

.hiw-pager a:last-child { text-align: right; }
.hiw-pager__direction {
  color: var(--text-muted);
  font: 600 var(--fs-xs)/1.2 var(--font-mono);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hiw-diagram {
  margin: var(--sp-5) 0;
  border: 1px solid var(--border);
  background: var(--surface-1);
}

.hiw-diagram__toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--sp-1);
  min-height: 42px;
  padding: 5px var(--sp-2);
  border-bottom: 1px solid var(--border);
}

.hiw-diagram__toolbar button {
  min-width: 34px;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: 600 var(--fs-xs)/1 var(--font-mono);
  cursor: pointer;
}

.hiw-diagram__toolbar button:hover {
  border-color: var(--border);
  color: var(--text);
}

.hiw-diagram__toolbar button:focus-visible,
.hiw-lens-button:focus-visible,
.hiw-pager a:focus-visible,
.hiw-chapter-grid a:focus-visible {
  outline: 2px solid var(--copper);
  outline-offset: 2px;
}

.hiw-diagram__toolbar button:disabled {
  cursor: not-allowed;
  opacity: .36;
}

.hiw-diagram__viewport {
  max-height: min(72vh, 760px);
  padding: var(--sp-4);
  overflow: auto;
}

.hiw-diagram .mermaid {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
}

.hiw-diagram .mermaid svg {
  display: block;
  width: var(--hiw-diagram-width, 100%) !important;
  max-width: none !important;
  height: auto;
  margin-inline: auto;
}

.hiw-diagram--expanded {
  position: fixed;
  z-index: var(--z-modal);
  inset: var(--sp-3);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  margin: 0;
  box-shadow: var(--shadow-2);
}

.hiw-diagram--expanded .hiw-diagram__viewport { max-height: none; }
body:has(.hiw-diagram--expanded) { overflow: hidden; }

@media (max-width: 820px) {
  .hiw-layout {
    grid-template-columns: 1fr;
  }

  .hiw-toc {
    position: static;
  }

  .hiw-toc__list {
    flex-direction: row;
    flex-wrap: wrap;
    border-left: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--sp-3, 8px);
  }

  .hiw-toc__list a {
    border-left: none;
    border-bottom: 2px solid transparent;
    padding: var(--sp-1, 4px) var(--sp-2);
  }

  .hiw-toc__list a[aria-current="page"] {
    border-bottom-color: var(--copper, var(--warn));
  }

  .hiw-honesty-strip,
  .hiw-section-heading,
  .hiw-lens-panels,
  .hiw-chapter-grid,
  .hiw-pager {
    grid-template-columns: 1fr;
  }

  .hiw-chapter-grid li:last-child:nth-child(odd) { grid-column: auto; }
  .hiw-chapter-grid a { grid-template-columns: auto minmax(0, 1fr); }
  .hiw-chapter-grid a > span:last-child { display: none; }
  .hiw-pager a:last-child { text-align: left; }
}

/* Public product entry and shared recovery states — Quiet Power register. */
.public-product {
  background:
    radial-gradient(circle at 78% 16%, color-mix(in srgb, var(--primary) 10%, transparent), transparent 28rem),
    var(--surface-1);
}

.public-product main { width: 100%; max-width: none; padding: 0; }
.product-landing { width: min(100%, 1560px); margin-inline: auto; padding: clamp(32px, 6vw, 92px) clamp(20px, 5vw, 80px) clamp(48px, 8vw, 112px); }
.product-hero { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); align-items: center; gap: clamp(40px, 7vw, 112px); min-height: min(720px, calc(100vh - 104px)); }
.product-hero__copy h1 { max-width: 930px; margin: var(--sp-3) 0 var(--sp-4); font: 520 clamp(48px, 6.2vw, 94px)/.98 var(--font-editorial); letter-spacing: -.055em; text-wrap: balance; }
.product-hero__deck { max-width: 730px; color: var(--text-muted); font-size: clamp(18px, 1.7vw, 25px); line-height: 1.55; }
.product-actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); margin: var(--sp-6) 0 var(--sp-4); }
.product-actions .btn { min-height: 48px; }
.product-cta { gap: var(--sp-2); }
.product-honesty { max-width: 700px; padding-top: var(--sp-3); border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-sm); }

.instrument-preview { position: relative; overflow: hidden; border: 1px solid color-mix(in srgb, var(--primary) 34%, var(--border)); background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 6%, transparent) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--primary) 6%, transparent) 1px, transparent 1px), var(--surface-2); background-size: 48px 48px; box-shadow: var(--shadow-1); }
.instrument-preview::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--copper); content: ""; }
.instrument-preview__topline,
.instrument-preview__boundary { display: flex; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); font: 650 var(--fs-xs)/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.trace-spine { display: grid; gap: 0; margin: 0; padding: var(--sp-4); list-style: none; }
.trace-spine li { position: relative; display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: var(--sp-3); padding: var(--sp-3) 0; }
.trace-spine li:not(:last-child)::after { position: absolute; top: 42px; bottom: -8px; left: 16px; width: 1px; background: var(--border); content: ""; }
.trace-spine li > span { color: var(--copper); font: 650 var(--fs-xs)/1.5 var(--font-mono); }
.trace-spine strong,
.trace-spine small { display: block; }
.trace-spine strong { font-size: var(--fs-md); }
.trace-spine small { margin-top: 4px; color: var(--text-muted); }
.instrument-preview__boundary { border-top: 1px solid var(--border); border-bottom: 0; color: var(--text-muted); line-height: 1.6; letter-spacing: 0; text-transform: none; }

.proof-grid { display: grid; grid-template-columns: minmax(260px, .65fr) minmax(0, 1.35fr); gap: clamp(32px, 6vw, 96px); padding: clamp(48px, 7vw, 96px) 0; border-block: 1px solid var(--border); }
.product-section-heading h2,
.product-path h2 { max-width: 760px; margin-top: var(--sp-2); font-size: clamp(30px, 4vw, 56px); letter-spacing: -.04em; }
.proof-grid__items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--border); background: var(--border); }
.proof-grid__items article { padding: clamp(20px, 2.5vw, 36px); background: var(--surface-1); }
.proof-grid__items h3 { margin: var(--sp-3) 0 var(--sp-2); font-size: var(--fs-lg); }
.proof-grid__items p { color: var(--text-muted); line-height: 1.65; }
.proof-index { color: var(--copper); font: 650 var(--fs-xs)/1 var(--font-mono); text-transform: uppercase; }

.product-path { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--sp-6); padding-top: clamp(48px, 7vw, 96px); }
.product-path__actions { display: grid; gap: var(--sp-2); text-align: right; }
.product-path__actions a { font-weight: 650; }

.recovery-page main { display: grid; min-height: calc(100vh - 190px); place-items: center; }
.recovery-state { width: min(100% - 32px, 720px); padding: clamp(28px, 5vw, 64px); border: 1px solid var(--border); background: var(--surface-1); }
.recovery-state__code,
.recovery-state__request { color: var(--text-muted); font: 650 var(--fs-xs)/1.4 var(--font-mono); letter-spacing: .08em; text-transform: uppercase; }
.recovery-state h1 { margin: var(--sp-3) 0; font-size: clamp(36px, 6vw, 64px); letter-spacing: -.045em; }
.recovery-state__message { max-width: 58ch; color: var(--text-muted); font-size: var(--fs-lg); line-height: 1.6; }
.recovery-state__preserved { padding: var(--sp-3); border-left: 2px solid var(--primary); background: var(--surface-2); }
.recovery-state__actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-5); }
.recovery-state__request { margin-top: var(--sp-5); overflow-wrap: anywhere; }

@media (max-width: 960px) {
  .product-hero,
  .proof-grid,
  .product-path { grid-template-columns: 1fr; }
  .product-hero { min-height: 0; }
  .proof-grid__items { grid-template-columns: 1fr; }
  .product-path__actions { text-align: left; }
}

@media (max-width: 560px) {
  .product-landing { padding-inline: 16px; }
  .product-hero__copy h1 { font-size: clamp(42px, 14vw, 62px); overflow-wrap: anywhere; }
  .instrument-preview { min-width: 0; }
  .product-actions .btn { width: 100%; justify-content: center; }
}
