/* Self-hosted fonts — Cyrillic + Latin, no Google CDN */
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/manrope-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/manrope-600-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-700.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/manrope-700-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/manrope-800.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Manrope";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/manrope-700-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-400.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/inter-400-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/inter-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/inter-400-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/inter-600-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/jbmono-500.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/static/fonts/jbmono-500-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/jbmono-600.woff2") format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/jbmono-500-lat.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: dark;
  --bg: #050508;
  --bg-elevated: #0A0E14;
  --glass: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.12);
  --nebula: #EF233C;
  --fire: #EF233C;
  --fire-warm: #FF6B35;
  --alert: #EF233C;
  --warn: #FFD166;
  --ok: #4ADE80;
  --mute: #71717A;
  --text: #E8E8EC;
  --text2: #A1A1AA;
  --header-h: 4.25rem;
  --header-offset: 0px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --font: "Inter", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Manrope", "Inter", system-ui, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --gap: 1.5rem;
  --glow-red: 0 0 30px rgba(239, 35, 60, 0.12);
  --map-h: min(52dvh, 560px);
  --map-h-min: 320px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
  position: relative;
}

button, input, select { font: inherit; color: inherit; }
a { color: var(--nebula); text-decoration: none; }
a:hover { color: #ff4d63; }

h1, h2, h3, .brand-name, .font-display {
  font-family: var(--font-display);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* —— Atmosphere —— */
.atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.starfield {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 40px 70px, #fff, transparent),
    radial-gradient(1px 1px at 50px 160px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90px 40px, #fff, transparent),
    radial-gradient(1px 1px at 130px 80px, #fff, transparent),
    radial-gradient(1.5px 1.5px at 160px 120px, #fff, transparent),
    radial-gradient(1px 1px at 180px 50px, rgba(255,255,255,0.7), transparent);
  background-repeat: repeat;
  background-size: 200px 200px;
  opacity: 0.14;
  animation: starDrift 120s linear infinite;
}

.nebula-glow {
  position: absolute;
  top: 40%;
  left: 50%;
  width: min(900px, 90vw);
  height: min(640px, 70vh);
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at center, rgba(239, 35, 60, 0.14) 0%, transparent 70%);
  filter: blur(80px);
  animation: nebulaPulse 8s ease-in-out infinite;
}

.nebula-glow--side {
  top: 18%;
  left: auto;
  right: -8%;
  transform: none;
  width: 520px;
  height: 520px;
  background: radial-gradient(circle at center, rgba(239, 35, 60, 0.1) 0%, transparent 72%);
  animation: nebulaPulseSide 8s ease-in-out infinite;
  animation-delay: -3s;
}

@keyframes starDrift {
  from { background-position: 0 0; }
  to { background-position: 200px 80px; }
}

@keyframes nebulaPulse {
  0%, 100% { opacity: 0.85; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
}

@keyframes nebulaPulseSide {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* —— Top bar in document flow (does not float over the map) —— */
.header-shell {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  width: 100%;
  transform: none;
  padding: 0.65rem 1rem;
  padding-top: calc(0.65rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
}

.header {
  height: 56px;
  max-width: 1320px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(9rem, 0.9fr) auto minmax(7rem, 0.85fr);
  align-items: center;
  gap: 0.55rem;
  padding: 0 0.85rem;
  border-radius: 16px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: block;
  object-fit: contain;
  border-radius: 6px;
}

.brand-name {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}

.brand-sub {
  display: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.15rem;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.68rem;
  color: var(--text2);
  white-space: nowrap;
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: center;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.15);
}

.status-pill.is-loading .status-dot {
  background: #ffd166;
  animation: tk-pulse-dot 1s ease-in-out infinite;
}

@keyframes tk-pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.1rem;
  justify-content: center;
  align-items: center;
  padding: 0.18rem;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  min-width: 0;
  overflow: visible;
}

.nav button {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text2);
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.42rem 0.72rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
  transition: color 0.2s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.nav button:hover {
  color: #fff;
  border-color: rgba(239, 35, 60, 0.28);
  box-shadow: 0 0 14px rgba(239, 35, 60, 0.1);
}

.nav button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  min-width: 0;
}

.header-actions .icon-btn,
.header-actions .lang-toggle {
  flex-shrink: 0;
}

.icon-btn {
  appearance: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
}

.icon-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(239, 35, 60, 0.35);
  box-shadow: 0 0 12px rgba(239, 35, 60, 0.12);
}

.lang-toggle {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  width: 40px;
}

.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: block; }

html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html[data-theme="light"] .theme-toggle .icon-moon { display: block; }

/* —— Shell —— */
.app {
  position: relative;
  z-index: 1;
  min-height: calc(100dvh - var(--header-h));
  padding-top: 0;
  padding-bottom: 1.5rem;
}

.view {
  display: none;
  animation: fadeSlide 0.22s ease;
}

.view.active { display: block; }
.view.active.map-view { display: grid; }

/* Map page: map → period (dates) → KPIs — no overlap */
body.view-map {
  overflow: hidden;
  height: 100dvh;
}

body.view-map .app {
  height: calc(100dvh - var(--header-h) - env(safe-area-inset-top));
  min-height: 0;
  padding-bottom: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.view-map .map-view.active {
  display: flex !important;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  gap: 0.75rem;
  overflow: hidden;
  padding: 0.55rem 0 0.75rem;
  box-sizing: border-box;
  grid-template-rows: unset;
}

body.view-map .map-chrome,
body.view-map .map-chrome.is-broken-size {
  flex: 1 1 0;
  order: 0;
  min-height: 200px !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 1rem;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

body.view-map .period,
body.view-map .period.glass {
  flex: 0 0 auto;
  order: 1;
  position: relative;
  z-index: 2;
  margin: 0 auto;
  width: min(1200px, calc(100% - 2rem));
  border-radius: var(--radius-lg);
  background: #0e0e14 !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: none;
  padding: 1rem 1.25rem 0.95rem;
  overflow: visible;
}

body.view-map .kpis {
  flex: 0 0 auto;
  order: 2;
  margin: 0 auto;
  width: min(1200px, calc(100% - 2rem));
  max-height: none;
  overflow: visible;
  position: relative;
  z-index: 2;
}

body.view-map .period-meta {
  margin-top: 0.55rem;
  padding-top: 0.5rem;
}

@media (max-width: 1024px) {
  body.view-map .app {
    height: calc(100dvh - var(--header-h) - env(safe-area-inset-top) - 3.75rem);
  }
  body.view-map .map-view.active {
    gap: 0.6rem;
    padding: 0.4rem 0 calc(0.55rem + env(safe-area-inset-bottom));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  body.view-map .map-chrome,
  body.view-map .map-chrome.is-broken-size {
    margin: 0 0.65rem;
    min-height: 280px !important;
    flex: 0 0 auto;
    /* Larger default mobile map — expand goes even bigger */
    height: min(56dvh, 480px) !important;
  }
  body.view-map .period,
  body.view-map .period.glass {
    width: calc(100% - 1.25rem);
    padding: 0.9rem 1rem 0.85rem;
  }
  body.view-map .kpis {
    width: calc(100% - 1.25rem);
  }

  .map-expand-btn {
    display: inline-flex !important;
  }
}

@media (max-width: 768px) {
  body.view-map .map-chrome,
  body.view-map .map-chrome.is-broken-size {
    height: min(52dvh, 440px) !important;
    min-height: 260px !important;
  }
  body.view-map .period-row {
    flex-direction: column;
    align-items: stretch;
  }
  body.view-map .field input {
    width: 100%;
    min-width: 0;
  }
  body.view-map #applyBtn {
    width: 100%;
  }
}

/* Mobile map expand — fullscreen within app chrome, collapse restores CSS height */
.map-expand-btn {
  display: none;
}

body.map-expanded {
  overflow: hidden;
}

body.map-expanded.view-map .map-view.active {
  overflow: hidden !important;
  padding: 0.35rem 0 0.35rem !important;
  gap: 0 !important;
}

body.map-expanded.view-map .period,
body.map-expanded.view-map .period.glass,
body.map-expanded.view-map .kpis {
  display: none !important;
}

body.map-expanded.view-map .map-chrome,
body.map-expanded.view-map .map-chrome.is-broken-size,
body.map-expanded.view-map .map-chrome.is-expanded {
  flex: 1 1 auto !important;
  margin: 0 0.5rem !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 14px;
}

body.map-expanded .bottom-nav {
  opacity: 0.35;
  pointer-events: none;
}

body.map-expanded .map-expand-btn {
  display: inline-flex !important;
  background: rgba(239, 35, 60, 0.22);
  border-color: rgba(239, 35, 60, 0.45);
  color: #fff;
}

@media (min-width: 1025px) {
  .map-expand-btn {
    display: none !important;
  }
  body.map-expanded.view-map .period,
  body.map-expanded.view-map .kpis {
    display: block !important;
  }
  body.map-expanded.view-map .period.glass {
    display: block !important;
  }
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: var(--radius-lg);
}

/* —— Map view —— */
.map-view {
  grid-template-rows: auto auto auto;
  min-height: calc(100vh - var(--header-offset));
  width: min(1440px, 100%);
  margin: 0 auto;
  gap: 0;
}

.map-chrome {
  position: relative;
  isolation: isolate;
  margin: 0 1rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
  /* Default stage size when NOT on map flex page */
  height: var(--map-h);
  min-height: var(--map-h-min);
  max-height: none;
}

/* On map page flex layout wins — never pin fixed dvh height */
body.view-map .map-chrome,
body.view-map .map-chrome.is-broken-size {
  height: auto !important;
  min-height: 160px !important;
  max-height: none !important;
}

.map-chrome.is-broken-size {
  height: var(--map-h) !important;
  min-height: var(--map-h-min) !important;
}

body.view-map .map-chrome.is-broken-size {
  height: auto !important;
  min-height: 160px !important;
}

.orbit-grid {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: radial-gradient(circle at center, black 40%, transparent 88%);
  -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 88%);
  opacity: 0.35;
}

#ymap {
  position: absolute !important;
  inset: 0;
  z-index: 2;
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  max-height: none !important;
  background: #07070c;
  cursor: grab;
  /* Keep map paint cheap — no backdrop/filter on the container */
  contain: layout paint;
}

#ymap:active {
  cursor: grabbing;
}

/* Neutralize Yandex inline size mutations that break chrome after controls/theme */
#ymap > ymaps,
#ymap > .ymaps-2-1-79-map,
#ymap > [class*="ymaps-"][class*="-map"] {
  width: 100% !important;
  height: 100% !important;
}

.map-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  text-align: center;
  color: var(--text2);
  background: rgba(5, 5, 8, 0.85);
  z-index: 5;
  font-size: 0.9rem;
}

/* Dark UI uses chrome/atmosphere — do NOT filter map tiles (kills pan FPS) */
#ymap.ymap-dark::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(5, 5, 8, 0.28) 0%,
    rgba(5, 5, 8, 0.12) 45%,
    rgba(5, 5, 8, 0.22) 100%
  );
}

html[data-theme="light"] #ymap.ymap-dark::after {
  display: none;
}

#ymap .ymaps-controls-pane {
  z-index: 2001 !important;
  pointer-events: auto !important;
}

/* Hide unused Yandex chrome leftovers */
#ymap .ymaps-search,
#ymap .ymaps-gototech,
#ymap .ymaps-copyright__logo-link {
  opacity: 0.55;
}

.map-toolbar {
  position: absolute;
  top: 1.1rem;
  left: 1.1rem;
  right: 1.1rem;
  z-index: 20;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
}

.map-layers {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.45rem;
  pointer-events: auto;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  pointer-events: auto;
}

.layer-btn,
.map-tool-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--glass-border);
  background: rgba(5, 5, 8, 0.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: var(--text);
  border-radius: var(--radius-pill);
  padding: 0.45rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.layer-btn:hover,
.map-tool-btn:hover {
  border-color: rgba(239, 35, 60, 0.45);
  color: var(--text);
  box-shadow: 0 0 16px rgba(239, 35, 60, 0.12);
}

.layer-btn .layer-label,
.map-tool-btn {
  color: inherit;
}

.layer-btn.active {
  border-color: rgba(239, 35, 60, 0.55);
  background: rgba(239, 35, 60, 0.18);
  color: #fff;
}

.swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.swatch-hot {
  background: var(--nebula);
  box-shadow: 0 0 8px var(--nebula);
}

.swatch-burn {
  background: var(--fire-warm);
  box-shadow: 0 0 8px rgba(255, 107, 53, 0.6);
}

.swatch-tech {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.45);
}

.map-hint {
  display: none !important;
}

.map-fallback {
  padding: 2rem;
  color: var(--text2);
}

.panel-note {
  margin: 0 0 0.75rem;
  color: var(--text2);
  font-size: 0.82rem;
  line-height: 1.45;
}

.empty-note {
  padding: 0.75rem;
  color: var(--mute);
  font-size: 0.85rem;
}

.kpi-delta {
  margin-top: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.kpi-delta.up { color: #FF8A80; }
.kpi-delta.down { color: #86EFAC; }
.kpi-delta.flat { color: #D1D5DB; }

.tag-nat { color: #FF8A80; }
.tag-tech { color: #D1D5DB; }

.cmp-pair {
  display: flex;
  gap: 2rem;
  align-items: end;
  min-height: 160px;
  padding: 0.5rem 0.25rem;
}

.cmp-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  height: 160px;
  justify-content: end;
}

.cmp-bar {
  width: 56px;
  border-radius: 10px 10px 4px 4px;
  min-height: 4px;
}

.cmp-bar.now { background: linear-gradient(180deg, #FF6B35, #EF233C); }
.cmp-bar.prev { background: rgba(255, 255, 255, 0.22); }

.cmp-col label {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text2);
  line-height: 1.35;
}

.cmp-empty {
  padding: 1rem 0.25rem;
  color: var(--mute);
  font-size: 0.85rem;
}

.heat-row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr 110px;
  gap: 0.6rem;
  align-items: center;
  margin: 0.45rem 0;
  font-size: 0.82rem;
}

.heat-track {
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.heat-track > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #FF6B35, #EF233C);
}

.legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
}

.legend .dot.s1 { background: #4ADE80; }
.legend .dot.s2 { background: #FFD166; }
.legend .dot.s3 { background: #EF233C; }

.api-url { margin: 0.35rem 0 1rem; color: var(--nebula); font-weight: 600; }

.curl-box {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.75rem;
}

.rates-body { display: grid; gap: 0.55rem; margin: 0.75rem 0 1rem; }

.rate-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.28);
}

/* —— Period —— */
.period,
.period.glass {
  margin: 0 auto;
  width: min(1200px, calc(100% - 2rem));
  padding: 0.95rem 1.25rem 0.85rem;
  border-radius: var(--radius-lg);
  position: relative;
  z-index: 5;
  background: #0e0e14 !important;
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.period-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #d4d4d8;
  line-height: 1.2;
  margin: 0;
  opacity: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.field input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 0.65rem 0.85rem;
  min-width: 10.5rem;
  color: var(--text);
  transition: border-color 0.2s;
  color-scheme: dark;
}

.field input:focus {
  outline: none;
  border-color: rgba(239, 35, 60, 0.45);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.chip {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text2);
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.chip:hover {
  color: #fff;
}

.chip.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sort-row .chip.active {
  background: rgba(239, 35, 60, 0.18);
  border-color: rgba(239, 35, 60, 0.35);
  color: var(--nebula);
}

.btn-fire {
  appearance: none;
  border: 0;
  background: var(--nebula);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  border-radius: 12px;
  padding: 0.7rem 1.5rem;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(239, 35, 60, 0.22);
  transition: filter 0.2s, transform 0.2s, box-shadow 0.2s;
}

.btn-fire:hover {
  filter: brightness(1.1);
  box-shadow: 0 10px 28px rgba(239, 35, 60, 0.3);
}

.period-meta {
  margin: 1rem 0 0;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  text-align: center;
  font-size: 0.78rem;
  color: var(--mute);
}

.region-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding: 0.35rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(239, 35, 60, 0.3);
  background: rgba(239, 35, 60, 0.08);
  color: var(--text);
  font-size: 0.8rem;
}

.region-chip button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text2);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

/* —— KPIs —— */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.15rem;
  width: min(1200px, calc(100% - 2rem));
  margin: 1.25rem auto 1.5rem;
}

.kpi {
  padding: 1.35rem 1.4rem;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), border-color 0.3s, box-shadow 0.3s;
  min-height: 148px;
  display: flex;
  flex-direction: column;
}

.kpi:hover {
  transform: translateY(-4px);
  border-color: rgba(239, 35, 60, 0.4);
  box-shadow: var(--glow-red);
}

.kpi-value {
  font-family: var(--mono);
  font-size: clamp(1.45rem, 2.2vw, 2rem);
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.03em;
  margin: 0.2rem 0 0.35rem;
}

.kpi-value.accent { color: var(--nebula); }

.kpi-label {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.72rem;
  color: var(--mute);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.kpi-break {
  margin-top: auto;
  padding-top: 0.75rem;
  font-size: 0.7rem;
  color: var(--mute);
  line-height: 1.45;
}

.sev-bar {
  display: flex;
  height: 4px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-top: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
}

.sev-bar span { display: block; height: 100%; }
.sev-bar .s1 { background: var(--ok); }
.sev-bar .s2 { background: var(--warn); }
.sev-bar .s3 { background: var(--nebula); }

/* —— Regions —— */
.regions-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: var(--gap);
  padding: 0 1.25rem 1.5rem;
  width: min(1200px, 100%);
  margin: 0 auto;
  min-height: calc(100vh - var(--header-offset) - 1rem);
}

.region-list {
  padding: 0;
  overflow: auto;
  max-height: calc(100vh - var(--header-offset) - 2rem);
  display: flex;
  flex-direction: column;
}

.region-list-head {
  padding: 1.25rem 1.25rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.region-list h2,
.panel h2,
.api-doc h2,
.region-detail > h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sort-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

#regionItems {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: auto;
  flex: 1;
}

.region-item {
  display: grid;
  grid-template-columns: 4px 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  transition: background 0.2s, border-color 0.2s;
}

.region-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(239, 35, 60, 0.28);
}

.region-item.active {
  background: rgba(239, 35, 60, 0.06);
  border-color: rgba(239, 35, 60, 0.4);
}

.region-item .bar {
  height: 70%;
  min-height: 22px;
  border-radius: 2px;
  background: var(--nebula);
}

.region-item .name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
}

.region-item .meta {
  font-size: 0.72rem;
  color: var(--mute);
  margin-top: 0.15rem;
}

.region-item .money {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--nebula);
  font-weight: 600;
}

.region-detail {
  padding: 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.region-detail .big {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.85rem;
  margin: 1rem 0;
}

.mini-card { padding: 1.1rem 1.15rem; }

.mini-card .v {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  color: #fff;
  margin: 0.25rem 0;
}

.mini-card .l {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 0;
}

.chart {
  height: 180px;
  margin: 0.75rem 0;
  position: relative;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.chart svg { width: 100%; height: 100%; }

.events { list-style: none; margin: 0; padding: 0; }

.events li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.65rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  font-size: 0.85rem;
  transition: background 0.15s;
}

.events li:hover { background: rgba(255, 255, 255, 0.02); }

.events .d {
  color: var(--mute);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.section-title {
  margin: 1rem 0 0.65rem;
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fff;
}

/* —— Analytics / Reports / API —— */
.panel-page {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto 2rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem;
}

.panel { padding: 1.35rem 1.45rem; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-head h2 {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.panel-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.45rem;
  align-items: end;
  height: 160px;
}

.bars .col {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.25rem;
  height: 100%;
}

.bars .pair { display: flex; gap: 3px; align-items: flex-end; height: 100%; }

.bars i {
  display: block;
  width: 100%;
  border-radius: 4px 4px 0 0;
  min-height: 4px;
}

.bars .now { background: var(--nebula); }
.bars .prev { background: rgba(255, 255, 255, 0.18); }

.bars label {
  font-size: 0.65rem;
  color: var(--mute);
  text-align: center;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 1rem;
  align-items: center;
}

.legend {
  font-size: 0.82rem;
  color: var(--text2);
  line-height: 1.8;
}

.legend b {
  color: #fff;
  font-family: var(--mono);
  font-weight: 600;
}

.report-list { list-style: none; margin: 0; padding: 0; }

.report-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  transition: background 0.15s;
}

.report-list li:hover { background: rgba(255, 255, 255, 0.03); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  display: none;
  place-items: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-backdrop.open { display: grid; }

.modal {
  width: min(480px, 100%);
  padding: 1.35rem;
}

.modal h3 {
  margin: 0 0 0.85rem;
  font-family: var(--font-display);
  font-weight: 700;
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-ghost {
  appearance: none;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text2);
  border-radius: 12px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-ghost:hover,
a.btn-ghost:hover {
  color: #fff;
  border-color: rgba(239, 35, 60, 0.4);
  background: rgba(239, 35, 60, 0.08);
}

.api-doc pre {
  margin: 0.75rem 0 0;
  padding: 1rem 1.15rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.78rem;
  line-height: 1.55;
  color: #d6d6d6;
}

.api-doc .key { color: #f87171; }
.api-doc .str { color: #fcd34d; }

.endpoint {
  display: flex;
  gap: 0.55rem;
  align-items: baseline;
  margin: 1rem 0 0.25rem;
  font-family: var(--mono);
  font-size: 0.85rem;
}

.endpoint .m {
  color: var(--nebula);
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: rgba(239, 35, 60, 0.12);
  border: 1px solid rgba(239, 35, 60, 0.25);
}

/* —— Toast —— */
.toasts {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.toast {
  min-width: 220px;
  max-width: 320px;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(5, 5, 8, 0.9);
  backdrop-filter: blur(16px);
  font-size: 0.82rem;
  color: var(--text);
  animation: fadeSlide 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* —— Skeleton —— */
.skel {
  background: linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease infinite;
  border-radius: 6px;
  color: transparent !important;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* —— Mobile bottom nav —— */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(0.65rem + env(safe-area-inset-bottom));
  z-index: 90;
  background: rgba(5, 5, 8, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 0.35rem 0.3rem;
  justify-content: space-around;
  gap: 0.15rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
}

.bottom-nav button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--mute);
  font-size: 0.62rem;
  font-weight: 600;
  padding: 0.35rem 0.2rem;
  min-height: 48px;
  min-width: 56px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  border-radius: 12px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
}

.bottom-nav button .bn-ico {
  font-size: 0.95rem;
  line-height: 1;
  color: inherit;
  opacity: 0.9;
}

.bottom-nav button.active {
  color: #fff;
  background: rgba(239, 35, 60, 0.16);
}

/* —— Scrollbar —— */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* —— Responsive —— */
@media (max-width: 1440px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1100px) {
  .header {
    grid-template-columns: 1fr auto;
  }
  .nav { display: none; }
  .status-pill { display: none; }
}

@media (max-width: 1024px) {
  :root { --header-h: 4.75rem; }

  .header-shell {
    padding: 0.5rem 0.625rem;
    padding-top: calc(0.5rem + env(safe-area-inset-top));
  }

  .header {
    height: 52px;
    padding: 0 0.75rem;
    border-radius: 14px;
  }

  .brand { gap: 0.5rem; }
  .brand-name { font-size: 0.95rem; }
  .header-actions { gap: 0.3rem; flex-shrink: 0; }
  .icon-btn { width: 40px; height: 40px; }

  .app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
  }

  .regions-layout {
    grid-template-columns: 1fr;
    padding: 0 0.75rem 1rem;
    gap: 0.85rem;
  }

  .region-list {
    max-height: none;
    order: 2;
  }

  .region-detail { order: 1; }
  .panel-grid { grid-template-columns: 1fr; }

  .panel-page {
    width: calc(100% - 1.25rem);
    margin: 0 auto 1rem;
  }

  .bottom-nav {
    display: flex;
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
  }

  .map-view {
    min-height: auto;
    grid-template-rows: auto auto auto;
  }

  .map-chrome {
    margin: 0 0.65rem;
  }

  body.view-map .map-chrome,
  body.view-map .map-chrome.is-broken-size {
    height: auto !important;
    min-height: 140px !important;
  }

  /* Keep export / theme / lang visible — never collapse header actions */
  .header-actions {
    display: flex !important;
  }
  #exportBtn,
  #themeBtn,
  #langBtn,
  #settingsBtn {
    display: grid !important;
  }

  .period {
    width: calc(100% - 1.25rem);
    margin: 0 auto;
  }

  .period-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .presets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.35rem;
  }

  .presets .chip {
    text-align: center;
    min-height: 40px;
    justify-content: center;
    display: inline-flex;
    align-items: center;
  }

  #applyBtn {
    width: 100%;
    min-height: 44px;
  }

  .toasts {
    left: max(0.75rem, env(safe-area-inset-left));
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: calc(5.75rem + env(safe-area-inset-bottom));
    align-items: stretch;
  }

  .toast {
    max-width: none;
    min-width: 0;
  }
}

@media (max-width: 768px) {
  .kpis {
    grid-template-columns: 1fr 1fr;
    width: calc(100% - 1.25rem);
    gap: 0.65rem;
    margin: 1rem auto;
  }

  .kpi {
    padding: 1rem;
    min-height: 120px;
  }

  .kpi-value {
    font-size: 1.2rem;
    margin: 0.1rem 0 0.25rem;
  }

  .kpi-label { font-size: 0.65rem; }
  .kpi-break { font-size: 0.65rem; }

  .period {
    padding: 1rem;
  }

  .field input {
    width: 100%;
    min-width: 0;
    font-size: 16px;
    min-height: 44px;
  }

  .map-toolbar {
    top: 0.55rem;
    left: 0.55rem;
    right: 0.55rem;
    gap: 0.35rem;
  }

  .layer-btn {
    padding: 0.45rem 0.55rem;
    min-height: 40px;
  }

  .layer-btn .layer-label {
    max-width: 9ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .map-hint {
    left: 0.55rem;
    right: 0.55rem;
    max-width: none;
    bottom: 0.55rem;
    font-size: 0.7rem;
  }

  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .region-detail .big { grid-template-columns: 1fr; }

  .heat-row {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .report-list li {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-head {
    flex-direction: column;
    align-items: stretch;
  }

  .modal {
    width: 100%;
    max-height: calc(100vh - 2rem - env(safe-area-inset-bottom) - env(safe-area-inset-top));
    overflow: auto;
  }

  .modal-backdrop {
    padding:
      max(1rem, env(safe-area-inset-top))
      max(1rem, env(safe-area-inset-right))
      max(1rem, env(safe-area-inset-bottom))
      max(1rem, env(safe-area-inset-left));
  }

  .api-doc pre,
  .curl-box {
    font-size: 0.68rem;
  }
}

@media (max-width: 480px) {
  .kpis { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .status-pill { display: none; }

  .header {
    height: 52px;
    padding: 0 0.55rem;
  }

  .header-actions { gap: 0.2rem; }
  .icon-btn,
  .lang-toggle {
    width: 36px;
    height: 36px;
  }

  .map-chrome {
    /* height controlled by flex on map page */
  }

  body.view-map .map-chrome,
  body.view-map .map-chrome.is-broken-size {
    height: auto !important;
    min-height: 120px !important;
  }

  .brand-name {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .layer-btn .layer-label { display: none; }

  .layer-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 12px;
  }

  .map-actions { margin-left: auto; }

  .bottom-nav button {
    font-size: 0.58rem;
    min-width: 0;
    flex: 1;
  }
}

@media (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  body.view-map .map-chrome,
  body.view-map .map-chrome.is-broken-size {
    height: auto !important;
    min-height: 100px !important;
  }

  .kpis { grid-template-columns: repeat(4, 1fr); }
  .status-pill { display: none; }
}

/* —— Light theme —— */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F7;
  --bg-elevated: #ffffff;
  --glass: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(15, 23, 42, 0.10);
  --nebula: #EF233C;
  --fire: #EF233C;
  --mute: #64748B;
  --text: #0F172A;
  --text2: #64748B;
  --glow-red: 0 0 28px rgba(239, 35, 60, 0.10);
}

html[data-theme="light"] .starfield {
  display: none;
}

html[data-theme="light"] .nebula-glow {
  background: radial-gradient(circle at center, rgba(239, 35, 60, 0.08) 0%, transparent 72%);
  opacity: 0.85;
}

html[data-theme="light"] .nebula-glow--side {
  background: radial-gradient(circle at center, rgba(239, 35, 60, 0.06) 0%, transparent 72%);
}

html[data-theme="light"] .header {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(15, 23, 42, 0.10);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .brand-name,
html[data-theme="light"] .nav button:hover,
html[data-theme="light"] .nav button.active,
html[data-theme="light"] .icon-btn:hover,
html[data-theme="light"] .chip:hover,
html[data-theme="light"] .chip.active,
html[data-theme="light"] .kpi-value,
html[data-theme="light"] .region-item .name,
html[data-theme="light"] .mini-card .v,
html[data-theme="light"] .section-title,
html[data-theme="light"] .legend b,
html[data-theme="light"] .btn-ghost:hover,
html[data-theme="light"] a.btn-ghost:hover {
  color: var(--text);
}

html[data-theme="light"] .kpi-value.accent {
  color: var(--nebula);
}

html[data-theme="light"] .nav {
  background: rgba(15, 23, 42, 0.04);
}

html[data-theme="light"] .nav button.active {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text);
}

html[data-theme="light"] .status-pill {
  background: rgba(15, 23, 42, 0.03);
}

html[data-theme="light"] .icon-btn:hover {
  background: rgba(239, 35, 60, 0.06);
}

html[data-theme="light"] .map-chrome {
  background: rgba(255, 255, 255, 0.65);
  border-color: rgba(15, 23, 42, 0.10);
}

html[data-theme="light"] .orbit-grid {
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.04) 1px, transparent 1px);
  opacity: 0.45;
}

html[data-theme="light"] #ymap {
  background: #e8eaef;
}

html[data-theme="light"] #ymap .ymaps-layers-pane,
html[data-theme="light"] #ymap .ymaps-ground-pane,
html[data-theme="light"] #ymap .ymaps-tiles-pane {
  filter: none;
}

html[data-theme="light"] .layer-btn,
html[data-theme="light"] .map-tool-btn {
  background: rgba(255, 255, 255, 0.94);
  color: #0F172A;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .layer-btn:hover,
html[data-theme="light"] .map-tool-btn:hover {
  color: #0F172A;
}

html[data-theme="light"] .layer-btn.active {
  background: rgba(239, 35, 60, 0.10);
  color: #0F172A;
}

html[data-theme="light"] .map-hint {
  background: rgba(255, 255, 255, 0.92);
  color: #334155;
  border-color: rgba(15, 23, 42, 0.10);
}

html[data-theme="light"] .period,
html[data-theme="light"] .period.glass,
html[data-theme="light"] body.view-map .period,
html[data-theme="light"] body.view-map .period.glass {
  background: #ffffff !important;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html[data-theme="light"] .period-meta {
  color: #64748B;
}

html[data-theme="light"] .field label {
  color: #334155;
  text-shadow: none;
}

html[data-theme="light"] .field input {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.14);
  color-scheme: light;
}

html[data-theme="light"] .presets {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.03);
}

html[data-theme="light"] .chip.active {
  background: rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .sort-row .chip.active {
  background: rgba(239, 35, 60, 0.10);
  color: var(--nebula);
}

html[data-theme="light"] .period-meta {
  border-top-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .sev-bar {
  background: rgba(15, 23, 42, 0.06);
}

html[data-theme="light"] .region-list-head {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .region-item {
  border-color: rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.72);
}

html[data-theme="light"] .region-item:hover {
  background: #fff;
}

html[data-theme="light"] .region-item.active {
  background: rgba(239, 35, 60, 0.06);
}

html[data-theme="light"] .chart {
  background: rgba(15, 23, 42, 0.02);
  border-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .events li {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .events li:hover {
  background: rgba(15, 23, 42, 0.03);
}

html[data-theme="light"] .bars .prev,
html[data-theme="light"] .cmp-bar.prev {
  background: rgba(15, 23, 42, 0.18);
}

html[data-theme="light"] .heat-track {
  background: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .report-list li {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

html[data-theme="light"] .report-list li:hover {
  background: rgba(15, 23, 42, 0.03);
}

html[data-theme="light"] .modal-backdrop {
  background: rgba(15, 23, 42, 0.35);
}

html[data-theme="light"] .btn-ghost {
  background: #fff;
}

html[data-theme="light"] .rate-row {
  background: rgba(15, 23, 42, 0.03);
}

html[data-theme="light"] .api-doc pre {
  background: #fff;
  border-color: rgba(15, 23, 42, 0.10);
  color: #334155;
}

html[data-theme="light"] .api-doc .key { color: #dc2626; }
html[data-theme="light"] .api-doc .str { color: #b45309; }

html[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .bottom-nav {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 32px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .bottom-nav button.active {
  background: rgba(239, 35, 60, 0.10);
  color: var(--nebula);
}

html[data-theme="light"] .skel {
  background: linear-gradient(90deg, rgba(15,23,42,0.04), rgba(15,23,42,0.09), rgba(15,23,42,0.04));
  background-size: 200% 100%;
}

html[data-theme="light"] .kpi-delta.flat,
html[data-theme="light"] .tag-tech {
  color: #64748B;
}

html[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.15);
}

html[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.28);
}
