/* ==========================================================================
   ИАП АИК — тема «Атлас». По мотивам таджикской ткани атлас (адрас, икат):
   кремовый «бумажный» фон, плоские насыщенные цвета, чёткие линии и почти прямые углы,
   крупные жирные цифры и полоса с икат-узором (ступенчатые ромбы) в шапке страницы и подвале.
   Без градиентов и «стекла». Действует только при data-theme="atlas"; основа — светлые токены.
   Цвет раздела — идентичность раздела, а не данные: палитры графиков не меняются.
   Соседние пары цветов разделов проверены на различимость при дальтонизме.
   ========================================================================== */

:root[data-theme="atlas"] {
  /* бумага и чернила */
  --bg: #F4EEE2;
  --panel: #FFFCF6;
  --panel-2: #F8F2E7;
  --panel-3: #EFE6D6;
  --line: #E0D5C2;
  --line-strong: #C9BBA3;
  --ink: #1C1A17;
  --ink-2: #4A433B;
  --ink-3: #6B6257;
  --overlay: rgba(244, 238, 226, .82);

  /* акцент — индиго */
  --accent: #2B3A8F;
  --accent-hover: #1F2B6E;
  --accent-ink: #FFFFFF;
  --accent-soft: rgba(43, 58, 143, .09);
  --accent-line: rgba(43, 58, 143, .40);
  --focus: #2B3A8F;

  --grid: #ECE3D2;
  --axis: #C9BBA3;
  --chart-label: #6B6257;
  --spark: #A89C8A;
  --skeleton: #EFE6D6;
  --meter-track: #EADFCB;
  --meter-fill: #2B3A8F;

  /* формы: почти прямые углы, плоские тени */
  --r-sm: 2px;
  --r-md: 3px;
  --r-lg: 4px;
  --shadow-1: none;
  --shadow-pop: 0 0 0 1px var(--line-strong), 6px 6px 0 rgba(28, 26, 23, .10);

  /* цвета разделов (I–VII) */
  --sec-I: #3446A0;   /* индиго — общие климатические */
  --sec-II: #0F86A8;  /* бирюза — вода */
  --sec-III: #1D6B3E; /* изумруд — лес */
  --sec-IV: #7A3F96;  /* слива — промышленность */
  --sec-V: #B87513;   /* шафран — сельское хозяйство */
  --sec-VI: #A12C66;  /* гранат — транспорт */
  --sec-VII: #D2691A; /* медь — энергетика */

  /* икат: ступенчатые ромбы (марена, шафран) на индиго, кремовая сердцевина, бирюзовые точки */
  --deep: #1F2758;
  --saffron: #F2C46B;
  --ikat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 16'%3E%3Crect width='64' height='16' fill='%2327357F'/%3E%3Cpolygon fill='%23B3261E' points='18,0 18,2 21,2 21,4 24,4 24,6 27,6 27,10 24,10 24,12 21,12 21,14 18,14 18,16 14,16 14,14 11,14 11,12 8,12 8,10 5,10 5,6 8,6 8,4 11,4 11,2 14,2 14,0'/%3E%3Cpolygon fill='%23E0A12A' points='50,0 50,2 53,2 53,4 56,4 56,6 59,6 59,10 56,10 56,12 53,12 53,14 50,14 50,16 46,16 46,14 43,14 43,12 40,12 40,10 37,10 37,6 40,6 40,4 43,4 43,2 46,2 46,0'/%3E%3Cpolygon fill='%23F4EEE2' points='18,4 18,6 21,6 21,10 18,10 18,12 14,12 14,10 11,10 11,6 14,6 14,4'/%3E%3Cpolygon fill='%23B3261E' points='50,4 50,6 53,6 53,10 50,10 50,12 46,12 46,10 43,10 43,6 46,6 46,4'/%3E%3Crect x='30' y='6' width='4' height='4' fill='%231B8FA6'/%3E%3Crect x='62' y='6' width='2' height='4' fill='%231B8FA6'/%3E%3Crect x='0' y='6' width='2' height='4' fill='%231B8FA6'/%3E%3C/svg%3E");
}
:root[data-theme="atlas"] [data-sec] { --sec: var(--accent); --sec-ink: color-mix(in srgb, var(--sec) 78%, #000); }
:root[data-theme="atlas"] [data-sec="I"] { --sec: var(--sec-I); }
:root[data-theme="atlas"] [data-sec="II"] { --sec: var(--sec-II); }
:root[data-theme="atlas"] [data-sec="III"] { --sec: var(--sec-III); }
:root[data-theme="atlas"] [data-sec="IV"] { --sec: var(--sec-IV); }
:root[data-theme="atlas"] [data-sec="V"] { --sec: var(--sec-V); }
:root[data-theme="atlas"] [data-sec="VI"] { --sec: var(--sec-VI); }
:root[data-theme="atlas"] [data-sec="VII"] { --sec: var(--sec-VII); }

:root[data-theme="atlas"] h1, :root[data-theme="atlas"] h2, :root[data-theme="atlas"] h3 { font-weight: 700; letter-spacing: -0.015em; }

/* ---------- шапка сайта: узорная кайма сверху ---------- */
:root[data-theme="atlas"] .topbar { background: var(--panel); border-bottom: 1px solid var(--line); }
:root[data-theme="atlas"] .topbar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: var(--ikat) repeat-x left top / 24px 6px; }
:root[data-theme="atlas"] .topbar-in { padding-top: 6px; }
:root[data-theme="atlas"] .brand-mark { background: var(--accent); color: #fff; }
:root[data-theme="atlas"] .brand-name { font-weight: 800; }
:root[data-theme="atlas"] .nav-link.is-active { background: transparent; color: var(--ink); border-radius: 0; box-shadow: inset 0 -2px 0 var(--ink); }
:root[data-theme="atlas"] .menu-item[data-sec] .menu-ico { background: var(--sec); color: #fff; }

/* ---------- шапка страницы: плоский цветной блок + икат-кайма снизу ---------- */
:root[data-theme="atlas"] .page-head {
  position: relative; overflow: hidden; color: #fff;
  padding: var(--sp-8) var(--sp-8) calc(var(--sp-8) + 22px);
  background: var(--deep); border-radius: var(--r-lg);
}
:root[data-theme="atlas"] .page-head[data-sec] { background: color-mix(in srgb, var(--sec) 78%, #000); }
:root[data-theme="atlas"] .page-head::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: var(--ikat) repeat-x left bottom / 88px 22px; }
:root[data-theme="atlas"] .page-head .overline { color: var(--saffron); font-weight: 700; }
:root[data-theme="atlas"] .page-head[data-sec] .overline { color: rgba(255, 255, 255, .86); }
:root[data-theme="atlas"] .page-head h1 { color: #fff; font-size: var(--fs-40); line-height: var(--lh-40); font-weight: 800; letter-spacing: -0.02em; }
:root[data-theme="atlas"] .page-head .lede,
:root[data-theme="atlas"] .page-head .body-2 { color: rgba(255, 255, 255, .88); }
:root[data-theme="atlas"] .page-head .muted-label { color: rgba(255, 255, 255, .72); }
:root[data-theme="atlas"] .page-head .code-lg { color: var(--saffron); }
:root[data-theme="atlas"] .page-head[data-sec] .code-lg { color: #fff; }
:root[data-theme="atlas"] .page-head .badge { background: var(--panel); }
:root[data-theme="atlas"] .page-head .sector-ico { background: rgba(255, 255, 255, .14); color: #fff; }
:root[data-theme="atlas"] .page-head .head-stats { gap: 0; align-self: stretch; align-items: flex-end; }
:root[data-theme="atlas"] .page-head .head-stat { min-width: 0; padding: 0 var(--sp-6); border-left: 1px solid rgba(255, 255, 255, .24); }
:root[data-theme="atlas"] .page-head .head-stat:first-child { border-left: 0; padding-left: 0; }
:root[data-theme="atlas"] .page-head .head-stat dt { color: rgba(255, 255, 255, .74); text-transform: uppercase; letter-spacing: var(--tracking-caps); font-weight: 600; }
:root[data-theme="atlas"] .page-head .head-stat dd { color: rgba(255, 255, 255, .72); }
:root[data-theme="atlas"] .page-head .head-stat dd b { color: #fff; font-size: var(--fs-40); line-height: var(--lh-40); font-weight: 800; letter-spacing: -0.02em; }
:root[data-theme="atlas"] .page-head .meter { background: rgba(255, 255, 255, .18); border-radius: 0; }
:root[data-theme="atlas"] .page-head .meter > span { background: var(--saffron); border-radius: 0; }
:root[data-theme="atlas"] .page-head .btn { background: transparent; border-color: rgba(255, 255, 255, .55); color: #fff; }
:root[data-theme="atlas"] .page-head .btn:hover { background: rgba(255, 255, 255, .12); color: #fff; }
:root[data-theme="atlas"] .page-head .btn-primary { background: var(--saffron); border-color: var(--saffron); color: var(--ink); }
:root[data-theme="atlas"] .page-head .btn-primary:hover { background: #F6D38E; color: var(--ink); }

/* ---------- фильтры, переключатели, вкладки ---------- */
:root[data-theme="atlas"] .seg button[aria-pressed="true"],
:root[data-theme="atlas"] .seg button[aria-selected="true"] { background: var(--ink); color: var(--panel); box-shadow: none; }
:root[data-theme="atlas"] .tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
:root[data-theme="atlas"] .btn-primary { background: var(--accent); border-color: var(--accent); }

/* ---------- карточки: плоские, с линейками ---------- */
:root[data-theme="atlas"] .card { box-shadow: none; }
:root[data-theme="atlas"] .card-main,
:root[data-theme="atlas"] .card.combo { border-top: 3px solid var(--ink); }
:root[data-theme="atlas"] .card .overline { color: var(--accent); font-weight: 700; }
:root[data-theme="atlas"] .group-row th { background: var(--panel-3); }
:root[data-theme="atlas"] .section-head { border-bottom: 2px solid var(--ink); padding-bottom: var(--sp-2); margin-bottom: var(--sp-4); }
:root[data-theme="atlas"] .section-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }

/* карточка показателя: цветная кромка раздела, код на плашке, жирное число */
:root[data-theme="atlas"] .kpi {
  --spark: var(--sec); box-shadow: none; overflow: hidden; padding-top: calc(var(--sp-4) + 4px);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
:root[data-theme="atlas"] .kpi::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 6px; background: var(--sec); }
:root[data-theme="atlas"] .kpi .code { background: var(--sec-ink); color: #fff; padding: 2px 6px; border-radius: var(--r-sm); }
:root[data-theme="atlas"] .kpi-value .num { font-weight: 800; font-size: 32px; line-height: 38px; }
:root[data-theme="atlas"] .kpi .spark-line { stroke-width: 2; }
:root[data-theme="atlas"] .kpi .spark-dot { fill: var(--sec); }
:root[data-theme="atlas"] .kpi .spark-dot.hollow { fill: var(--panel); stroke: var(--sec); }
:root[data-theme="atlas"] .kpi:hover { border-color: var(--ink); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--sec); }

/* плитки разделов: цветной заголовок-плашка с номером */
:root[data-theme="atlas"] .sector-tile[data-sec] {
  --spark: var(--sec); padding: 0 0 var(--sp-4); overflow: hidden; gap: var(--sp-2);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
:root[data-theme="atlas"] .sector-tile[data-sec] > :not(.sector-tile-head) { margin-inline: var(--sp-4); }
:root[data-theme="atlas"] .sector-tile[data-sec] .sector-tile-head { background: var(--sec); color: #fff; padding: var(--sp-2) var(--sp-4); margin-bottom: var(--sp-1); }
:root[data-theme="atlas"] .sector-tile[data-sec] .sector-ico { background: transparent; color: #fff; width: 28px; height: 28px; }
:root[data-theme="atlas"] .sector-tile[data-sec] .code { color: #fff; font-size: var(--fs-20); line-height: var(--lh-20); font-weight: 800; }
:root[data-theme="atlas"] .sector-tile[data-sec] h3 { font-weight: 700; }
:root[data-theme="atlas"] .sector-tile[data-sec] .meter { background: color-mix(in srgb, var(--sec) 16%, transparent); border-radius: 0; height: 6px; }
:root[data-theme="atlas"] .sector-tile[data-sec] .meter > span { background: var(--sec); border-radius: 0; }
:root[data-theme="atlas"] .sector-tile[data-sec] .spark-dot { fill: var(--sec); }
:root[data-theme="atlas"] .sector-tile[data-sec]:hover { background: var(--panel); border-color: var(--ink); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--ink); }
:root[data-theme="atlas"] .sector-tile-all { position: relative; overflow: hidden; background: var(--ink); border: 0; color: var(--panel); padding-bottom: calc(var(--sp-4) + 12px); }
:root[data-theme="atlas"] .sector-tile-all::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 12px; background: var(--ikat) repeat-x left bottom / 48px 12px; }
:root[data-theme="atlas"] .sector-tile-all h3 { color: var(--panel); font-weight: 800; }
:root[data-theme="atlas"] .sector-tile-all .lede { color: rgba(255, 252, 246, .80); }
:root[data-theme="atlas"] .sector-tile-all .link-more { color: var(--saffron); }
:root[data-theme="atlas"] .sector-tile-all .sector-ico { background: rgba(255, 255, 255, .12); color: var(--saffron); }
:root[data-theme="atlas"] .sector-tile-all:hover { background: var(--ink); color: var(--panel); transform: translate(-2px, -2px); box-shadow: 4px 4px 0 #E0A12A; }

/* структура и происхождение данных */
:root[data-theme="atlas"] .stack-seg:last-child { border-radius: 0; }
:root[data-theme="atlas"] .meter { border-radius: 0; }
:root[data-theme="atlas"] .meter > span { border-radius: 0; }
:root[data-theme="atlas"] .source-list .meter { height: 8px; }
:root[data-theme="atlas"] .source-list li:nth-child(1) .meter > span { background: var(--good); }
:root[data-theme="atlas"] .source-list li:nth-child(2) .meter,
:root[data-theme="atlas"] .source-list li:nth-child(3) .meter { background: var(--warn-soft); }
:root[data-theme="atlas"] .source-list li:nth-child(2) .meter > span,
:root[data-theme="atlas"] .source-list li:nth-child(3) .meter > span { background: var(--warn); }
:root[data-theme="atlas"] .source-list li:nth-child(4) .meter > span {
  background: repeating-linear-gradient(135deg, var(--ink-3) 0 4px, color-mix(in srgb, var(--ink-3) 35%, transparent) 4px 8px);
}

/* подвал: индиго с узорной каймой */
:root[data-theme="atlas"] .footer { position: relative; border-top: 0; background: var(--deep); margin-top: var(--sp-8); padding-top: 12px; }
:root[data-theme="atlas"] .footer::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 12px; background: var(--ikat) repeat-x left top / 48px 12px; }
:root[data-theme="atlas"] .footer-in { color: rgba(255, 255, 255, .76); }
:root[data-theme="atlas"] .footer-links a { color: var(--saffron); }

@media (max-width: 1100px) {
  :root[data-theme="atlas"] .page-head .head-stats { align-self: auto; }
}
@media (max-width: 640px) {
  :root[data-theme="atlas"] .page-head { padding: var(--sp-5) var(--sp-5) calc(var(--sp-5) + 22px); }
  :root[data-theme="atlas"] .page-head h1 { font-size: var(--fs-28); line-height: var(--lh-28); }
  :root[data-theme="atlas"] .page-head .head-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-3) 0; width: 100%; }
  :root[data-theme="atlas"] .page-head .head-stats:has(> .head-stat:nth-child(4)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root[data-theme="atlas"] .page-head .head-stat { padding: 0 var(--sp-3); }
  :root[data-theme="atlas"] .page-head .head-stat:nth-child(odd):has(~ .head-stat:nth-child(4)) { border-left: 0; padding-left: 0; }
  :root[data-theme="atlas"] .page-head .head-stat dd b { font-size: var(--fs-28); line-height: var(--lh-28); }
}
