:root {
  --sky-top: #b8d9ec;
  --sky-mid: #9ec9e3;
  --sky-bot: #e8f4fa;
  --cloud: #f7fbff;
  --cloud-shade: #d4e6f4;
  --ink: #2a4050;
  --ink-soft: #5a7385;
  --accent: #5aa0c8;
  --accent-deep: #3d7fa8;
  --accent-soft: #8ec4e0;
  --foreign: #6a9bb8;
  --foreign-deep: #4a7a96;
  --blush: #f2b6c4;
  --panel: rgba(255, 255, 255, 0.58);
  --panel-edge: rgba(255, 255, 255, 0.75);
  --radius: 18px;
  --font-display: "Segoe UI", "Trebuchet MS", "Candara", sans-serif;
  --font-body: "Segoe UI", "Candara", "Trebuchet MS", sans-serif;
  --ring-len: 289; /* 2π·46 */
  --indent: 1.25em; /* красная строка для абзацев по ширине */
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-mid) 42%, var(--sky-bot) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.sky {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.mist {
  position: absolute;
  width: 120%;
  height: 40%;
  left: -10%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.45), transparent 70%);
  animation: drift 18s ease-in-out infinite alternate;
}

.mist-a { top: 8%; opacity: 0.7; }
.mist-b { top: 55%; animation-duration: 24s; animation-delay: -6s; opacity: 0.5; }

@keyframes drift {
  from { transform: translateX(-3%); }
  to { transform: translateX(4%); }
}

.top,
.stage,
.foot {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  padding: 0 1.1rem;
}

.top {
  padding-top: 1.25rem;
}

/* [облачко | название (свои границы, без переноса)]
   [        | tagline ближе к облаку и правее к краю] */
.brand-row {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: 0.45rem;
  width: 100%;
}

.brand-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
  padding-right: 0;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 5.2vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
  text-align: left;
  white-space: nowrap;
  width: max-content;
  max-width: 100%;
}

.brand .tm {
  font-size: 0.52em;
  font-weight: 700;
  vertical-align: super;
  margin-left: 0.1em;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  line-height: 0;
}

.tagline {
  margin: 0.35rem 0 0;
  width: 100%;
  max-width: 100%;
  padding-right: 0.35rem; /* чуть не впритык к правой границе */
  box-sizing: border-box;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.4;
  text-align: justify;
  text-align-last: left;
  text-indent: var(--indent);
  hyphens: auto;
  -webkit-hyphens: auto;
}

/* Mini cloud accent — целая тучка, не обрезанное лицо */
.cloud-mini {
  flex: 0 0 88px;
  width: 88px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0.5rem 0.4rem;
  margin: 0;
  outline: none;
  transition: transform 0.08s ease;
  overflow: visible;
}

.cloud-mini:active,
.cloud-mini.squish {
  transform: scale(0.92);
}

.cloud-mini:focus-visible .cloud-body {
  box-shadow: 0 0 0 3px rgba(90, 160, 200, 0.55);
}

.cloud-body {
  position: relative;
  display: block;
  width: 64px;
  height: 42px;
  border-radius: 22px;
  background: linear-gradient(180deg, #ffffff 0%, var(--cloud) 55%, var(--cloud-shade) 100%);
  box-shadow:
    0 4px 0 rgba(90, 130, 160, 0.12),
    0 8px 14px rgba(60, 100, 140, 0.16);
  overflow: visible;
}

.puff {
  position: absolute;
  background: radial-gradient(circle at 35% 35%, #fff, var(--cloud) 60%, var(--cloud-shade));
  border-radius: 50%;
  pointer-events: none;
}

.p1 { width: 30px; height: 30px; left: -6px; top: -12px; }
.p2 { width: 36px; height: 36px; left: 16px; top: -18px; }
.p3 { width: 26px; height: 26px; right: -2px; top: -10px; }

.face {
  position: absolute;
  inset: 30% 18% 14%;
  z-index: 2;
}

.eye {
  position: absolute;
  top: 28%;
  width: 5px;
  height: 6px;
  background: var(--ink);
  border-radius: 50%;
  animation: blink 5.5s infinite;
}

.eye.left { left: 22%; }
.eye.right { right: 22%; }

@keyframes blink {
  0%, 92%, 100% { transform: scaleY(1); }
  95% { transform: scaleY(0.1); }
}

.blush {
  position: absolute;
  top: 52%;
  width: 7px;
  height: 5px;
  background: var(--blush);
  border-radius: 50%;
  opacity: 0.75;
}

.blush.left { left: 6%; }
.blush.right { right: 6%; }

.smile {
  position: absolute;
  left: 50%;
  bottom: 8%;
  width: 12px;
  height: 7px;
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  transform: translateX(-50%);
}

.stage {
  padding-top: 1.1rem;
  padding-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.95rem;
}

.unit-card {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 0.95rem 1.05rem 1rem;
  box-shadow: 0 8px 24px rgba(70, 110, 140, 0.1);
}

.unit-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-deep);
  text-align: center;
}

.unit-def {
  margin: 0.4rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-align: justify;
  text-align-last: left;
  text-indent: var(--indent);
  hyphens: auto;
  -webkit-hyphens: auto;
}

.view-switch {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}

.view-btn {
  border: 1px solid rgba(90, 130, 160, 0.28);
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.view-btn[aria-pressed="true"] {
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: transparent;
  box-shadow: 0 3px 0 rgba(40, 90, 120, 0.22);
}

.view-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.gauges {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .brand-row {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.45rem;
    align-items: start;
    width: 100%;
  }

  .brand-text {
    display: contents;
  }

  .brand {
    grid-column: 1 / -1;
    grid-row: 1;
    width: 100%;
    max-width: 100%;
    text-align: center;
    white-space: normal;
    justify-self: center;
  }

  .cloud-mini {
    grid-column: 1;
    grid-row: 2;
    flex: none;
    align-self: start;
    margin-top: 0.95rem;
  }

  .tagline {
    grid-column: 2;
    grid-row: 2;
    margin-top: 0;
    padding-right: 0;
  }

  .brand .tm,
  .tm {
    font-size: 0.85em;
    font-weight: 700;
    color: var(--ink);
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45);
  }
}

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

.gauge {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 0.9rem 0.85rem 1rem;
  box-shadow: 0 8px 22px rgba(70, 110, 140, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  min-height: 210px;
}

.gauge-head {
  text-align: center;
  width: 100%;
}

.gauge-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
}

.gauge-hint {
  margin: 0.2rem 0 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
}

.gauge-readout {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
}

.gauge-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-deep);
  transition: color 0.35s ease;
}

.gauge[data-contour="foreign"] .gauge-value {
  color: var(--foreign-deep);
}

.gauge-unit {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: lowercase;
}

/* Show only active viz mode */
.viz {
  display: none;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: 0.55rem;
  min-height: 88px;
}

.gauges[data-view="bars"] .viz-bars,
.gauges[data-view="rings"] .viz-rings,
.gauges[data-view="sectors"] .viz-sectors {
  display: flex;
}

/* Flat bars */
.bar-track {
  background: rgba(90, 130, 160, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.bar-h {
  flex: 1;
  height: 14px;
  max-width: 100%;
}

.bar-v {
  width: 14px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column-reverse;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent-deep));
  transition: width 0.55s ease, height 0.55s ease;
}

.bar-v .bar-fill {
  width: 100%;
  height: 0%;
  background: linear-gradient(180deg, var(--accent-deep), var(--accent-soft));
}

.bar-fill.foreign {
  background: linear-gradient(90deg, #9ebfd4, var(--foreign-deep));
}

.bar-v .bar-fill.foreign {
  background: linear-gradient(180deg, var(--foreign-deep), #9ebfd4);
}

/* Rings */
.ring-svg,
.sector-svg {
  display: block;
  overflow: visible;
}

.ring-track,
.sector-track {
  fill: none;
  stroke: rgba(90, 130, 160, 0.16);
  stroke-width: 10;
}

.ring-fill {
  fill: none;
  stroke: var(--accent-deep);
  stroke-width: 10;
  stroke-linecap: butt;
  stroke-dasharray: 0 100;
  stroke-dashoffset: 0;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dasharray 0.55s ease;
}

.ring-fill.foreign {
  stroke: var(--foreign-deep);
}

/* Sectors (pie wedge via path) */
.sector-fill {
  fill: var(--accent);
  opacity: 0.88;
}

.sector-fill.foreign {
  fill: var(--foreign);
}

.status-line {
  margin: 0;
  padding: 0.15rem 0;
  line-height: 1.35;
  text-align: center;
  box-sizing: border-box;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.toast {
  margin: 0;
  padding: 0;
  min-height: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  color: var(--accent-deep);
  text-align: center;
}

.toast[hidden] {
  display: none !important;
}

.toast:not([hidden]) {
  padding: 0.15rem 0;
}

.foot {
  text-align: center;
  padding: 0 1.1rem 1.25rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* Надпись в голубом зазоре между белыми блоками — одинаковый воздух сверху/снизу */
.foot p { margin: 0.25rem 0; }
.foot > p:first-child {
  margin: 0.95rem 0;
  padding: 0;
  line-height: 1.35;
  text-align: center;
}
.foot > p:first-child + p { margin-top: 0; }

.download-card {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.1rem;
  box-shadow: 0 8px 24px rgba(70, 110, 140, 0.1);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.download-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.download-def {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 28rem;
}

.download-btn {
  display: inline-block;
  margin-top: 0.25rem;
  padding: 0.7rem 1.15rem;
  border-radius: 14px;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 4px 0 rgba(40, 90, 120, 0.22);
  transition: transform 0.08s ease, filter 0.15s ease;
  max-width: 100%;
}

.download-btn:hover {
  filter: brightness(1.05);
}

.download-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(40, 90, 120, 0.22);
}

.download-btn:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 3px;
}

.download-btn.is-local {
  cursor: default;
  background: linear-gradient(180deg, #9ebfd4, #6a8fa8);
  box-shadow: none;
}

.disclaimer {
  max-width: 36rem;
  margin: 0 auto 0.45rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--ink-soft);
  background: color-mix(in srgb, #fff 55%, transparent);
  border-radius: 0.55rem;
  border: 1px solid color-mix(in srgb, var(--ink-soft) 18%, transparent);
  text-align: justify;
  text-align-last: left;
  text-indent: var(--indent);
  hyphens: auto;
  -webkit-hyphens: auto;
}
.fine {
  font-size: 0.75rem;
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  text-align: justify;
  text-align-last: left;
  text-indent: var(--indent);
  hyphens: auto;
  -webkit-hyphens: auto;
}
.fine.legal {
  margin: 0.55rem auto 0;
  max-width: 36rem;
  opacity: 0.78;
  letter-spacing: 0.01em;
  text-align: justify;
  text-align-last: left;
  text-indent: var(--indent);
  line-height: 1.45;
  hyphens: auto;
  -webkit-hyphens: auto;
}
.fine.muted {
  text-align: center;
  text-align-last: center;
  text-indent: 0;
}
.fine.copy {
  text-align: center;
  text-align-last: center;
  text-indent: 0;
  margin-top: 0.65rem;
  opacity: 0.78;
  letter-spacing: 0.01em;
}
.quiet { font-style: italic; }
.muted { opacity: 0.7; }

@media (prefers-reduced-motion: reduce) {
  .mist,
  .eye,
  .bar-fill,
  .ring-fill,
  .sector-fill {
    animation: none !important;
    transition: none !important;
  }
}
