/* Foreign trade analytics platform - base styles */

:root {
  --navy: #0e2a47;
  --navy-2: #16385c;
  --accent: #2f80ed;
  --green: #1e8e3e;
  --red: #d93025;
  --bg: #f2f5f9;
  --card-border: #e3e8ef;
  /* Semantic surfaces/text - overridden by the dark theme below */
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --th-bg: #f7f9fc;
  --text: #1b2733;
  --text-muted: #67788e;
  --tint-blue: #eef5ff;
}

/* Dark theme: same layout, dark surfaces. The navbar keeps its navy gradient
   (works in both), everything else swaps to dark backgrounds and light text. */
:root[data-theme="dark"] {
  --bg: #0f1720;
  --card-border: #2a3949;
  --surface: #17212e;
  --surface-2: #1e2a38;
  --th-bg: #1c2735;
  --text: #e5edf5;
  --text-muted: #9fb0c3;
  --tint-blue: #1a2a41;
}

body {
  background: var(--bg);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: clip;
}
body > main { flex: 1 0 auto; width: 100%; }

/* Navbar */
.app-navbar {
  min-height: 59px;
  padding-block: 2px;
  border-bottom: 1px solid rgba(244, 190, 64, .2);
  background:
    radial-gradient(680px 120px at 18% -80%, rgba(94,166,255,.28), transparent 72%),
    linear-gradient(96deg, #0b2744 0%, #113657 54%, #0d2c4c 100%);
  box-shadow: 0 8px 28px rgba(8, 27, 48, .24);
  isolation: isolate;
}
.app-navbar::after {
  content: "";
  position: absolute;
  z-index: -1;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, rgba(239,177,31,.7) 42%, rgba(86,204,242,.65) 58%, transparent 100%);
  background-size: 220% 100%;
  animation: navbarSignal 7s linear infinite;
}
@keyframes navbarSignal {
  from { background-position: 180% 0; }
  to { background-position: -40% 0; }
}
.app-navbar .container-fluid { min-height: 54px; }
.app-navbar .navbar-brand {
  min-width: 215px;
  padding-block: 5px;
  color: #fff;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(255,255,255,.14), rgba(255,255,255,.055));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 5px 18px rgba(4,18,34,.22);
  overflow: hidden;
  animation: brandBreath 4.8s ease-in-out infinite;
}
.brand-mark img {
  width: 37px;
  height: 37px;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(239,177,31,.16));
}
@keyframes brandBreath {
  0%, 100% { box-shadow: inset 0 1px 0 rgba(255,255,255,.15), 0 5px 18px rgba(4,18,34,.22); }
  50% { box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 5px 20px rgba(239,177,31,.18); }
}
.brand-title { font-size: .96rem; font-weight: 720; line-height: 1.12; letter-spacing: -.015em; }
.brand-sub { margin-top: 2px; font-size: .63rem; opacity: .68; line-height: 1.1; }
.app-navbar .nav-link {
  position: relative;
  color: #cfdeed;
  font-size: .84rem;
  font-weight: 620;
  border: 1px solid transparent;
  border-radius: 11px;
  padding: .48rem .72rem;
  transition: background .22s var(--ease), color .22s var(--ease),
              border-color .22s var(--ease), transform .22s var(--ease);
}
.app-navbar .nav-link.active,
.app-navbar .nav-link:hover { color: #fff; }
.app-navbar .nav-link:hover {
  border-color: rgba(255,255,255,.09);
  background: rgba(255,255,255,.075);
  transform: translateY(-1px);
}
.app-navbar .nav-link.active {
  border-color: rgba(255,255,255,.13);
  background: linear-gradient(145deg, rgba(255,255,255,.16), rgba(255,255,255,.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 5px 14px rgba(3,16,30,.12);
}
.app-navbar .nav-link.active::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 3px;
  left: 12px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, #efb11f, #f6d678);
}
.app-main-nav { gap: 2px; }
.nav-ico { margin-right: 0.4rem; font-size: 0.95em; }
@media (min-width: 1200px) and (max-width: 1399px) {
  .app-navbar .user-chip .d-none.d-xl-inline { display: none !important; }
  .app-navbar .navbar-search { max-width: 250px; }
}

/* User chip with avatar in the navbar */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  min-height: 40px;
  background: rgba(255,255,255,.035);
}
.avatar-circle {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6fb1ff, #2f80ed);
  color: #fff; font-weight: 700; font-size: 0.85rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 0 0 2px #ffffff2e;
}

.app-footer { color: #7d8da1; margin-top: 20px; flex: 0 0 auto; }

/* Cards */
.card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(16, 30, 54, 0.06);
}
.card {
  background: var(--surface);
  color: var(--text);
}
.card-header {
  background: var(--surface);
  color: var(--text);
  border-bottom: 1px solid var(--card-border);
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
}

/* KPI cards */
.kpi-card { padding: 1.1rem 1.25rem; }
.kpi-label { font-size: 0.8rem; color: #67788e; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; }
.kpi-sub { font-size: 0.82rem; color: #67788e; }
.kpi-delta { font-size: 0.88rem; font-weight: 600; }
.delta-up { color: var(--green); }
.delta-down { color: var(--red); }
.kpi-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.1rem; font-weight: 700;
}
.kpi-icon-exp { background: #e0edff; color: #1d5bbf; }
.kpi-icon-imp { background: #fdeceb; color: #b02a20; }
.kpi-icon-turn { background: #e8f7ee; color: #157347; }
.kpi-icon-bal { background: #fff6df; color: #8a6d00; }

/* Tables */
.table-analytic { font-size: 0.875rem; color: var(--text); }
.table-analytic th {
  background: var(--th-bg);
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.table-analytic th.sorted-asc::after { content: " ▲"; font-size: 0.7em; }
.table-analytic th.sorted-desc::after { content: " ▼"; font-size: 0.7em; }
.table-analytic td { vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.share-bar {
  display: inline-block; height: 6px; border-radius: 3px;
  background: var(--accent); vertical-align: middle; margin-right: 6px;
  min-width: 2px;
}

.pos { color: var(--green); font-weight: 600; }
.neg { color: var(--red); font-weight: 600; }

/* Chart containers */
.chart { width: 100%; min-height: 340px; }
.chart-tall { min-height: 480px; }
.chart-xtall { width: 100%; min-height: 560px; }

/* Overview hero: one card, three switchable views (Treemap / Xarita / Dinamika) */
.viz-hero .viz-title { font-size: 1.05rem; }
.viz-hero .card-header { padding-top: 0.9rem; padding-bottom: 0.9rem; }
.viz-switch .btn { min-width: 88px; }

/* ---- Modern dropdown menus (navbar and page-level) ---- */
.dropdown-menu {
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  box-shadow: 0 14px 38px rgba(16, 30, 54, 0.18);
  padding: 0.4rem;
  min-width: 230px;
  --bs-dropdown-link-active-bg: var(--tint-blue);
  --bs-dropdown-link-active-color: var(--accent);
}
@keyframes dd-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.dropdown-menu.show { animation: dd-in 0.16s ease; }
.user-actions-dropdown .dropdown-menu {
  transform-origin: top right;
}
@keyframes userActionsIn {
  from { opacity: 0; transform: translateY(-10px) scale(.96); }
  65% { opacity: 1; transform: translateY(1px) scale(1.004); }
  to { opacity: 1; transform: none; }
}
.user-actions-dropdown .dropdown-menu.show {
  animation: userActionsIn .3s var(--ease) both;
}
.dropdown-menu .dropdown-item {
  display: flex; align-items: center; gap: 0.6rem;
  border-radius: 9px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem; font-weight: 500;
  color: var(--text);
  transition: background 0.12s, color 0.12s;
}
.dropdown-menu .dropdown-item:hover { background: var(--tint-blue); color: var(--accent); }
.dropdown-menu .dropdown-item.active { background: var(--tint-blue); color: var(--accent); font-weight: 600; }
.dropdown-item .di-ico { width: 1.5em; text-align: center; flex-shrink: 0; }
.dropdown-item .di-check { width: 1.2em; color: var(--accent); font-weight: 700; }
.dropdown-menu .dropdown-header { padding: 0.55rem 0.75rem 0.35rem; color: var(--text); }
.dropdown-menu .dropdown-divider { margin: 0.35rem 0.5rem; border-color: var(--card-border); opacity: 1; }

/* ---- Modern select controls (all filter dropdowns) ---- */
.form-select {
  border-radius: 10px;
  border: 1.5px solid var(--card-border);
  font-weight: 500;
  color: var(--text);
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2367788e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 6 4 4 4-4'/%3e%3c/svg%3e");
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.form-select:hover { border-color: var(--accent); }
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}
.form-control { border-radius: 10px; transition: border-color 0.15s, box-shadow 0.15s; }
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}

/* ---------- Fancy select (custom, on-brand dropdown) ----------
   Replaces the browser's native option list. The real <select> is kept in the
   DOM but visually hidden (JS enhancement); if JS is off the native select
   shows normally, so this is pure progressive enhancement. */
.fancy-select { position: relative; display: inline-block; min-width: 0; vertical-align: middle; }
.fancy-select > select {
  position: absolute !important; left: 0; top: 0;
  width: 1px !important; height: 1px !important; min-width: 0 !important;
  opacity: 0; pointer-events: none; margin: 0; padding: 0; border: 0;
  clip: rect(0 0 0 0); overflow: hidden;
}
.fancy-select-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%;
  padding: 0.45rem 0.75rem;
  font-size: 0.9rem; font-weight: 500; line-height: 1.3;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.fancy-sm .fancy-select-btn { padding: 0.3rem 0.6rem; font-size: 0.82rem; }
.fancy-select-btn:hover { border-color: var(--accent); }
.fancy-select.open .fancy-select-btn,
.fancy-select-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.15);
}
.fancy-select-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fancy-select-caret { display: flex; flex: none; color: var(--text-muted); transition: transform 0.18s ease; }
.fancy-select.open .fancy-select-caret { transform: rotate(180deg); color: var(--accent); }

.fancy-select-menu {
  position: absolute; z-index: 50; top: calc(100% + 6px); left: 0;
  min-width: 100%; width: max-content; max-width: 280px;
  max-height: 264px; overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 14px 34px rgba(16, 32, 58, 0.18), 0 3px 10px rgba(16, 32, 58, 0.08);
  display: none;
}
.fancy-select.open .fancy-select-menu { display: block; animation: fsFade 0.14s ease; }
.fancy-select.drop-up .fancy-select-menu { top: auto; bottom: calc(100% + 6px); }
@keyframes fsFade { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }

.fancy-option {
  position: relative;
  padding: 0.45rem 0.7rem 0.45rem 1.9rem;
  border-radius: 8px;
  font-size: 0.87rem; font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}
.fancy-option + .fancy-option { margin-top: 1px; }
.fancy-option.is-active { background: var(--surface-2); }
.fancy-option.is-selected { color: var(--accent); font-weight: 700; }
.fancy-option.is-selected::before {
  content: ""; position: absolute; left: 0.68rem; top: 50%;
  width: 0.62rem; height: 0.34rem; margin-top: -0.28rem;
  border-left: 2px solid var(--accent); border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}
.fancy-select-menu::-webkit-scrollbar { width: 8px; }
.fancy-select-menu::-webkit-scrollbar-thumb { background: var(--card-border); border-radius: 8px; }

/* Filter bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

/* Insight block */
.insight-box {
  background: linear-gradient(135deg, #eef5ff, #f8fbff);
  border: 1px solid #d7e6fb;
  border-radius: 12px;
}
.insight-box .title { font-weight: 700; color: var(--navy); }

/* Upload drop zone */
.dropzone {
  position: relative;
  border: 2px dashed #b9c7d8;
  border-radius: 14px;
  background: #fff;
  padding: 3rem 2rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--accent); background: #eef5ff; }
/* The browser's own file input is replaced by the dropzone + the styled
   "Fayl tanlash" label, so it is hidden here in CSS — not from JS, which used
   to leave the raw control (rendered in the BROWSER's language, e.g.
   "Выберите файл") on screen whenever the page's inline script didn't run.
   Deliberately not display:none: the field is `required`, and a browser cannot
   focus a display:none control, which makes native validation block submit
   silently. Kept 1px and transparent so validation can still point at it. */
.dropzone input[type="file"] {
  position: absolute; left: 50%; bottom: 14px;
  width: 1px; height: 1px; opacity: 0;
  margin: 0; padding: 0; border: 0;
}
.dz-file-name:empty { display: none; }
.dz-pick { cursor: pointer; }
.dz-selection {
  display: flex;
  min-height: 32px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dz-file-name {
  display: inline-flex;
  max-width: min(100%, 440px);
  min-height: 30px;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--card-border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  overflow-wrap: anywhere;
  font-size: 12px;
}
.dropzone.has-file {
  border-color: color-mix(in srgb, var(--accent) 65%, var(--card-border));
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
}

/* Status badges */
.status-badge { font-size: 0.78rem; padding: 0.35em 0.7em; border-radius: 20px; font-weight: 600; }
.st-pending { background: #fff4d6; color: #8a6d00; }
.st-processing { background: #e0edff; color: #1d5bbf; }
.st-success { background: #dcf2e3; color: #157347; }
.st-failed { background: #fbe0de; color: #b02a20; }
.st-needs_confirm { background: #ffe8d1; color: #9a5b00; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1d4a75 100%);
}
.login-card { width: 100%; max-width: 400px; border-radius: 16px; }
.auth-brand-mark {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 16px;
  background: #103453;
  box-shadow: 0 10px 26px rgba(7,25,43,.22), inset 0 1px 0 rgba(255,255,255,.08);
}
.auth-brand-mark img {
  display: block;
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.scroll-table { max-height: 560px; overflow-y: auto; }
.scroll-table thead th { position: sticky; top: 0; z-index: 2; }

/* Dynamics report: a narrower, centred table with the prior- and current-year
   value columns tinted apart, and collapsible breakdown groups (aircraft). */
.report-table th:first-child, .report-table td:first-child { min-width: 320px; }
/* Body columns keep a subtle tint; the sticky header must stay fully OPAQUE so
   rows scrolling under it don't show through (uses the solid --th-bg). */
.report-table tbody .rep-col-prior { background: rgba(120, 140, 170, 0.06); }
.report-table tbody .rep-col-cur { background: rgba(47, 128, 237, 0.07); }
.report-table thead th { background: var(--th-bg); }
.report-table thead .rep-col-prior { box-shadow: inset 0 0 0 999px rgba(120, 140, 170, 0.10); }
.report-table thead .rep-col-cur { box-shadow: inset 0 0 0 999px rgba(47, 128, 237, 0.12); }
[data-group-head] { cursor: pointer; }
.rep-caret { display: inline-block; width: 1.1em; color: var(--accent); font-size: 0.8em; }

a.code-link { text-decoration: none; font-weight: 600; color: var(--accent); }
a.code-link:hover { text-decoration: underline; }
/* Clickable country/product names: pointer cursor even over the inner
   truncable span (whose default copy-cursor would otherwise win). */
a.code-link, a.code-link .truncable { cursor: pointer; }

/* Long names - full text on hover (title), click to copy.
   Inside tables the name wraps so the full text is always visible. */
.truncable {
  cursor: copy;
}
td .truncable {
  display: inline-block;
  max-width: 520px;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Chart drill-down breadcrumb */
.chart-crumb { font-size: 0.82rem; color: #64748b; min-height: 20px; margin-bottom: 4px; }
.chart-crumb .crumb-link { color: var(--accent); text-decoration: none; }
.chart-crumb .crumb-link:hover { text-decoration: underline; }

/* Ranking position number */
.rank-cell { color: #94a3b8; font-weight: 700; text-align: center; width: 38px; font-variant-numeric: tabular-nums; }

/* Global search (navbar autocomplete) */
.search-wrap {
  position: relative;
  width: clamp(230px, 22vw, 350px);
  max-width: 40vw;
  border-radius: 12px;
}
.search-wrap input {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 40px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 12px;
  background: rgba(255,255,255,.095);
  color: #fff;
  padding: .4rem 2.35rem .4rem 2.35rem;
  font-size: .82rem;
  backdrop-filter: blur(10px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06);
  transition: background .22s var(--ease), border-color .22s var(--ease),
              box-shadow .22s var(--ease), transform .22s var(--ease);
}
.search-wrap input::placeholder { color: #ffffff99; }
.search-wrap input:focus {
  border-color: rgba(86,204,242,.75);
  background: #fff;
  color: #16283c;
  outline: none;
  box-shadow: 0 0 0 4px rgba(86,204,242,.13), 0 10px 28px rgba(4,18,34,.18);
  transform: translateY(-1px);
}
.search-leading {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 12px;
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.7);
  pointer-events: none;
  transform: translateY(-50%);
  transition: color .2s var(--ease), transform .2s var(--ease);
}
.search-wrap:focus-within .search-leading {
  color: var(--accent);
  transform: translateY(-50%) scale(1.08);
}
.search-beacon {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: 13px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #56ccf2;
  box-shadow: 0 0 0 0 rgba(86,204,242,.55);
  pointer-events: none;
  transform: translateY(-50%);
  animation: searchBeacon 2.2s ease-out infinite;
}
@keyframes searchBeacon {
  0%, 35% { box-shadow: 0 0 0 0 rgba(86,204,242,.48); opacity: 1; }
  72%, 100% { box-shadow: 0 0 0 7px rgba(86,204,242,0); opacity: .62; }
}
.search-wrap:focus-within .search-beacon { background: var(--accent); }
#search-results {
  display: none;
  position: absolute;
  z-index: 1000;
  top: calc(100% + 9px);
  right: 0;
  left: 0;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 18px 44px rgba(8, 26, 46, .24);
  animation: searchResultsIn .2s var(--ease);
}
@keyframes searchResultsIn {
  from { opacity: 0; transform: translateY(-6px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.search-item {
  display: flex; align-items: center; gap: 10px; padding: 0.55rem 0.85rem;
  text-decoration: none; color: var(--text); border-bottom: 1px solid var(--card-border);
}
.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--tint-blue); }
.si-icon { font-size: 1rem; }
.si-label { flex: 1; font-weight: 500; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-sub { font-size: 0.72rem; color: #8494a8; white-space: nowrap; }

/* Upload page format guide */
.format-guide {
  background: #f6f9fe; border: 1px solid var(--card-border);
  border-radius: 10px; padding: 0.75rem 1rem;
}
.format-guide > summary {
  cursor: pointer; color: #1d5bbf; list-style: none;
}
.format-guide > summary::-webkit-details-marker { display: none; }
.format-guide[open] > summary { margin-bottom: 0.25rem; }
.format-guide table { font-size: 0.8rem; }
.format-guide code { font-size: 0.78rem; color: #1b3a5c; background: #eaf1fb; padding: 0 3px; border-radius: 3px; }

/* Trade-dynamics control panel */
.dyn-toolbar {
  background: #f8fafd;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
}
.dyn-header-note { font-size: 0.78rem; font-weight: 500; color: #7d8da1; }
.dyn-toolbar-row {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}
.dyn-group { display: flex; flex-direction: column; gap: 0.35rem; }
.dyn-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #6c7d92;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.dyn-segmented .btn { white-space: nowrap; }
.dyn-link-btn {
  border: none;
  background: none;
  padding: 0;
  margin-left: 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--accent);
  cursor: pointer;
}
.dyn-link-btn:hover { text-decoration: underline; }

/* 3-column dynamics grid: row 1 = mode tiles, row 2 = each mode's controls
   sitting directly under its own tile. */
.dyn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  align-items: start;
}
.dyn-grid .dyn-mode-tile { width: 100%; margin: 0; }
.dyn-cell { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.dyn-cell .dyn-group { width: 100%; }
.dyn-cell .dyn-years-panel { margin-top: 0; }
/* Column 1: value + flow segmented controls side-by-side on ONE row, directly
   under the "Oylar oralig'i" tile (value has 2 options, flow has 3 → 2:3). */
.dyn-cell-inline { flex-direction: row; align-items: flex-start; gap: 12px; }
.dyn-cell-inline > .dyn-group { width: auto; min-width: 0; }
.dyn-cell-inline > .dyn-group:nth-child(1) { flex: 2 1 0; }
.dyn-cell-inline > .dyn-group:nth-child(2) { flex: 4 1 0; }
.dyn-cell-inline .dyn-segmented .btn { padding-left: 0.3rem; padding-right: 0.3rem; }
.dyn-cell-inline .dyn-segmented .btn {
  min-width: 0;
  height: 38px;
  padding: 3px 4px;
  white-space: normal;
  font-size: 9.5px;
  line-height: 1.08;
}
/* Column 2: period range picker on a SINGLE line (yil oy → yil oy), spanning
   the same width as the "Bir oy — yillar kesimida" tile above it. The column
   is only ~1/3 of the card, so every px is scarce: the year box is a hard
   floor (flex-shrink:0) sized just for "YYYY" so the number can NEVER clip;
   the caret is dropped and padding/gap tightened to buy room; the month box
   absorbs whatever is left and, on a genuinely narrow viewport, ellipsises
   its label rather than pushing the row out of the column.
   NOTE: never give this row overflow-x/y. Each dropdown menu is an absolutely
   positioned child of a .fancy-select inside this row, so ANY overflow value
   here turns the row into a clipping container and slices the open menu off
   (and makes scrollIntoView yank the row sideways). Keep it overflow:visible. */
.dyn-cell .dyn-period-picker {
  flex-wrap: nowrap;
  gap: 4px;
}
.dyn-period-picker .fancy-select-btn { padding: 0.28rem 0.4rem; gap: 0; }
.dyn-period-picker .fancy-select-caret { display: none; }
.dyn-period-picker .fancy-select:has(select[name^="dy"]) { flex: 0 0 46px; min-width: 46px; }
.dyn-period-picker .fancy-select:has(select[name^="dm"]) { flex: 1 1 76px; min-width: 0; }
.dyn-cell .dyn-period-arrow { flex: none; padding: 0 1px; }
@media (max-width: 767px) {
  .dyn-grid { grid-template-columns: 1fr; }
}

/* Mode selector: descriptive tiles */
.dyn-modes { display: flex; gap: 10px; flex-wrap: wrap; }
.dyn-mode-tile {
  flex: 1 1 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.dyn-mode-tile:hover { border-color: var(--accent); }
.dyn-mode-tile.active {
  border-color: var(--accent);
  background: #eef5ff;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.12);
}
.dyn-mode-ico { font-size: 1.25rem; }
.dyn-mode-body { display: flex; flex-direction: column; line-height: 1.25; }
.dyn-mode-title { font-size: 0.85rem; font-weight: 700; color: #1b2733; }
.dyn-mode-tile.active .dyn-mode-title { color: #1d5bbf; }
.dyn-mode-desc { font-size: 0.72rem; color: #7d8da1; }

/* Period range picker: clean bordered selects (no transparent/borderless
   hack, which collided with the global .form-select arrow and doubled the
   rendered text). Each select is a normal small form-select. */
.dyn-period-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.dyn-period-picker select { min-width: 92px; }
.dyn-period-arrow { color: var(--text-muted); font-weight: 700; padding: 0 2px; font-size: 1.05rem; }

/* Month picker: 12-button grid */
.dyn-month-grid { display: flex; gap: 6px; flex-wrap: wrap; }
.dyn-month-btn {
  min-width: 52px;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: #46586e;
  cursor: pointer;
  text-transform: capitalize;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.dyn-month-btn:hover { border-color: var(--accent); }
.dyn-month-btn.active {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.18);
}

/* Year multi-select: scrollable panel that stays usable with many years */
.dyn-years-panel {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
}
.dyn-years-head { display: flex; align-items: center; gap: 4px; margin-bottom: 0.5rem; flex-wrap: wrap; }
.dyn-badge {
  display: inline-block;
  background: #e0edff;
  color: #1d5bbf;
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0.1rem 0.5rem;
  text-transform: none;
  letter-spacing: 0;
}
.dyn-years { display: flex; gap: 6px; flex-wrap: wrap; }
.dyn-years-scroll { max-height: 96px; overflow-y: auto; padding: 2px; }
.dyn-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.32rem 0.7rem;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  color: #46586e;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.dyn-chip:hover { border-color: var(--accent); }
.dyn-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.dyn-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 3px rgba(47, 128, 237, 0.18);
}

.dyn-apply-btn { align-self: center; }

/* Dynamics loading indicator: shown only while the HTMX request is in flight
   (hx-indicator adds .htmx-request to this element). */
.dyn-loading { display: none; align-items: center; gap: 8px; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 6px; }
.dyn-loading.htmx-request { display: flex; }
.dyn-spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--card-border); border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bigger dynamics chart now that the filters are compact */
#dyn-chart.chart-tall { min-height: 520px; }
.hero-panel-dynamics .dyn-toolbar {
  flex: 0 0 auto;
  margin-bottom: 6px !important;
  padding: 8px;
}
.hero-panel-dynamics > .loading-host {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}
.hero-panel-dynamics #dyn-chart.chart-tall {
  flex: 1 1 auto;
  min-height: 0;
  height: 100% !important;
}

@media (max-width: 767px) {
  .dyn-toolbar-row { gap: 0.9rem; }
  .dyn-apply-btn { width: 100%; }
  .dyn-mode-tile { flex-basis: 100%; }
  .dyn-period-picker { width: 100%; }
  .dyn-period-picker select { flex: 1 1 40%; min-width: 0; }
}

/* ---- Mobile polish: keep numbers and icons inside their cards ---- */
@media (max-width: 575px) {
  .kpi-card { padding: 0.9rem 1rem; }
  .kpi-value { font-size: 1.4rem; overflow-wrap: anywhere; }
  .kpi-icon { flex-shrink: 0; width: 40px; height: 40px; }
  .kpi-card .kpi-icon,
  .kpi-card .bosh-card-ico { margin-left: 0.5rem; }
  /* The boshqaruv coverage value is a wide date range - let it shrink and wrap
     instead of pushing past the card edge on a narrow screen. */
  .bosh-coverage-value { font-size: 0.95rem !important; overflow-wrap: anywhere; }
  .bosh-card { padding: 0.9rem 1rem; }
  .bosh-card-ico { width: 44px; height: 44px; font-size: 1.25rem; }
  .bosh-tabs { gap: 4px; }
  .bosh-tab { padding: 0.4rem 0.7rem; font-size: 0.8rem; }
  /* Wide analytic tables scroll within their card rather than stretching the
     page and overlapping neighbouring content. */
  .card-body > .table,
  .card-body > .table-analytic { display: block; overflow-x: auto; white-space: nowrap; }
}

/* Compact day/night control: the orbit remains gently animated so the action
   is discoverable without turning the navbar into a distracting banner. */
.theme-switch {
  position: relative;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 12px;
  background: rgba(255,255,255,.065);
  color: #f5d16c;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  transition: background .22s var(--ease), border-color .22s var(--ease),
              transform .22s var(--ease), box-shadow .22s var(--ease);
}
.theme-switch:hover {
  border-color: rgba(255,255,255,.25);
  background: rgba(255,255,255,.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 7px 18px rgba(3,16,30,.16);
  transform: translateY(-1px);
}
.theme-switch:active { transform: scale(.96); }
.theme-switch:focus-visible {
  outline: 3px solid rgba(86,204,242,.25);
  outline-offset: 2px;
}
.theme-glyph {
  position: absolute;
  display: grid;
  place-items: center;
  transition: opacity .35s var(--ease), transform .45s var(--ease);
}
.theme-sun { opacity: 1; transform: rotate(0) scale(1); }
.theme-moon { opacity: 0; transform: rotate(-28deg) scale(.55); }
:root[data-theme="dark"] .theme-sun { opacity: 0; transform: rotate(45deg) scale(.55); }
:root[data-theme="dark"] .theme-moon { opacity: 1; transform: rotate(0) scale(1); color: #c6dcff; }
.theme-orbit {
  position: absolute;
  width: 31px;
  height: 31px;
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 50%;
  animation: themeOrbit 5.5s linear infinite;
}
.theme-orbit i {
  position: absolute;
  top: -2px;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #56ccf2;
  box-shadow: 0 0 8px rgba(86,204,242,.8);
  transform: translateX(-50%);
}
@keyframes themeOrbit { to { transform: rotate(360deg); } }

/* ============================ DARK THEME ============================ */
:root[data-theme="dark"] body { color: var(--text); }

:root[data-theme="dark"] .card-body { color: var(--text); }
:root[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
:root[data-theme="dark"] .text-secondary { color: var(--text-muted) !important; }

/* Bootstrap tables */
:root[data-theme="dark"] .table { --bs-table-color: var(--text); --bs-table-bg: transparent; }
:root[data-theme="dark"] .table-hover > tbody > tr:hover > * {
  --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
  --bs-table-hover-color: var(--text);
}
:root[data-theme="dark"] .table > :not(caption) > * > * { border-color: var(--card-border); }
:root[data-theme="dark"] .table-light,
:root[data-theme="dark"] .table-light > * {
  --bs-table-bg: var(--surface-2); --bs-table-color: var(--text);
}

/* Form controls */
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
  background-color: var(--surface-2);
  border-color: var(--card-border);
  color: var(--text);
}
:root[data-theme="dark"] .form-control::placeholder { color: var(--text-muted); }
:root[data-theme="dark"] .form-select option { background: var(--surface); color: var(--text); }
:root[data-theme="dark"] .dropdown-menu {
  background: var(--surface); border-color: var(--card-border);
}
:root[data-theme="dark"] .dropdown-item { color: var(--text); }
:root[data-theme="dark"] .dropdown-item:hover { background: var(--surface-2); color: var(--text); }
:root[data-theme="dark"] .btn-outline-primary { color: #7fb0ff; border-color: #3f6ea8; }
:root[data-theme="dark"] .btn-outline-primary:hover { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .btn-outline-secondary { color: var(--text-muted); border-color: var(--card-border); }

/* App component surfaces */
:root[data-theme="dark"] .filter-bar,
:root[data-theme="dark"] .dyn-toolbar,
:root[data-theme="dark"] .dyn-years-panel,
:root[data-theme="dark"] .dyn-mode-tile,
:root[data-theme="dark"] .dyn-month-btn,
:root[data-theme="dark"] .dyn-chip,
:root[data-theme="dark"] .dyn-stat,
:root[data-theme="dark"] .format-guide,
:root[data-theme="dark"] #search-results,
:root[data-theme="dark"] .dropzone {
  background: var(--surface-2);
  border-color: var(--card-border);
  color: var(--text);
}
:root[data-theme="dark"] .dyn-mode-title,
:root[data-theme="dark"] .dyn-stat b { color: var(--text); }
:root[data-theme="dark"] .dyn-mode-tile.active {
  background: var(--tint-blue); border-color: var(--accent);
}
/* Selected month/year must keep the accent highlight in dark mode: the
   surface-2 rule above otherwise wins on specificity and hides the selection. */
:root[data-theme="dark"] .dyn-month-btn.active,
:root[data-theme="dark"] .dyn-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
:root[data-theme="dark"] .insight-box {
  background: linear-gradient(135deg, #14263d, #172230);
  border-color: #26405f;
}
:root[data-theme="dark"] .insight-box .title { color: #8fc0ff; }
:root[data-theme="dark"] .search-item { color: var(--text); border-color: var(--card-border); }
:root[data-theme="dark"] .search-item:hover { background: var(--surface-2); }
:root[data-theme="dark"] .format-guide code { background: #22303f; color: #a9c7e8; }
:root[data-theme="dark"] .format-guide table { color: var(--text); }
:root[data-theme="dark"] .chart-crumb { color: var(--text-muted); }

/* KPI icon tints stay legible on dark */
:root[data-theme="dark"] .kpi-label,
:root[data-theme="dark"] .kpi-sub { color: var(--text-muted); }

/* Login/waiting cards render on the same navy gradient; keep the card itself
   light-on-dark via the surface variable already applied to .card */
:root[data-theme="dark"] .login-card { background: var(--surface); }

/* ============================ BOSHQARUV SHELL ============================ */
.bosh-head-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(135deg, var(--navy), var(--accent));
  font-size: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(47, 128, 237, 0.3);
}
.bosh-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 6px;
}
.bosh-tab {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  font-weight: 600; font-size: 0.88rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.bosh-tab:hover { background: var(--tint-blue); color: var(--accent); }
.bosh-tab.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 2px 10px rgba(47, 128, 237, 0.35);
}
.bosh-tab .bt-ico { font-size: 1rem; }

/* Hub action cards */
.bosh-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  height: 100%;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.bosh-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(47, 128, 237, 0.16);
  transform: translateY(-2px);
  color: var(--text);
}
.bosh-card-ico {
  width: 52px; height: 52px; border-radius: 12px; flex-shrink: 0;
  background: var(--tint-blue);
  font-size: 1.5rem;
  display: inline-flex; align-items: center; justify-content: center;
}
.bosh-card-title { font-weight: 700; }
.bosh-card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.35; }
.bosh-card-arrow {
  margin-left: auto; color: var(--accent);
  font-weight: 700; font-size: 1.25rem;
  opacity: 0; transform: translateX(-4px);
  transition: opacity 0.15s, transform 0.15s;
}
.bosh-card:hover .bosh-card-arrow { opacity: 1; transform: none; }

/* "Almashtirilgan" marker in the upload history */
.badge-replaced {
  background: var(--tint-blue); color: var(--accent);
  border: 1px solid var(--card-border);
  font-size: 0.68rem; font-weight: 600;
  padding: 0.2em 0.55em; border-radius: 20px;
  vertical-align: middle;
}

/* System console (Boshqaruv → Tizim) sub-navigation */
.sys-subnav {
  display: flex; gap: 4px; flex-wrap: wrap;
  border-bottom: 2px solid var(--card-border);
  padding-bottom: 0;
}
.sys-link {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.12s, background 0.12s, border-color 0.12s;
}
.sys-link:hover { color: var(--accent); background: var(--tint-blue); }
.sys-link.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Membership country picker: region groups with a searchable checkbox grid */
.country-picker { max-height: 480px; overflow-y: auto; }
.cp-region { margin-bottom: 0.9rem; }
.cp-region-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 0.4rem; padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--card-border);
}
.cp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 4px 12px;
}
.cp-item {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.84rem; padding: 3px 6px;
  border-radius: 7px; cursor: pointer;
}
.cp-item:hover { background: var(--tint-blue); }
.cp-item input { accent-color: var(--accent); flex-shrink: 0; }

/* Modals follow the theme */
.modal-content {
  border-radius: 16px;
  border: 1px solid var(--card-border);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(16, 30, 54, 0.3);
}
:root[data-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Dark-theme select arrow stays visible */
:root[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239fb0c3' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 6 4 4 4-4'/%3e%3c/svg%3e");
}

/* ============================ MODERN THEME LAYER ============================
   Self-contained visual polish (no external assets): soft layered background,
   deeper card elevation with hover lift, gradient primary buttons, animated
   KPI tiles, page fade-in and a global HTMX progress bar. Everything reads
   from the existing CSS variables so it works in light and dark. */

:root {
  --shadow-sm: 0 1px 2px rgba(16, 30, 54, 0.05);
  --shadow-md: 0 6px 20px -10px rgba(16, 30, 54, 0.18);
  --shadow-lg: 0 18px 42px -18px rgba(16, 30, 54, 0.28);
  --ring: 0 0 0 3px rgba(47, 128, 237, 0.15);
}
:root[data-theme="dark"] {
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 20px 46px -18px rgba(0, 0, 0, 0.7);
}

/* Layered, faintly glowing background instead of a flat fill */
body {
  background-image:
    radial-gradient(1100px 560px at 100% -12%, rgba(47, 128, 237, 0.07), transparent 60%),
    radial-gradient(820px 460px at -8% 8%, rgba(111, 177, 255, 0.06), transparent 55%);
  background-attachment: fixed;
}
:root[data-theme="dark"] body {
  background-image:
    radial-gradient(1100px 560px at 100% -12%, rgba(47, 128, 237, 0.12), transparent 60%),
    radial-gradient(820px 460px at -8% 8%, rgba(20, 40, 70, 0.5), transparent 55%);
}

/* Smooth, consistent motion */
.card, .btn, .kpi-card, .bosh-card, .bosh-tab, .sys-link, .dropdown-item,
.form-control, .form-select, .status-badge, .nav-link {
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease,
              box-shadow 0.2s ease, transform 0.18s ease;
}

/* Cards: softer edges, layered elevation */
.card {
  border-radius: 16px;
  box-shadow: var(--shadow-sm), var(--shadow-md);
}
.card-header { background: transparent; border-bottom: 1px solid var(--card-border); }

/* Interactive tiles lift on hover */
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-icon { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25); }

/* Gradient primary buttons with a springy hover */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary {
  background: linear-gradient(135deg, #4d97f2, #2f80ed);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(47, 128, 237, 0.28);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #3f8cf0, #2673dd);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(47, 128, 237, 0.4);
}
.btn-success {
  background: linear-gradient(135deg, #28a558, #1e8e3e);
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(30, 142, 62, 0.25);
}
.btn-success:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(30, 142, 62, 0.38); }
.btn:active { transform: translateY(0); }
.btn-outline-primary:hover { transform: translateY(-1px); }

/* Focus rings */
.btn:focus-visible, .form-control:focus, .form-select:focus { box-shadow: var(--ring); }

/* Page content eases in */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
main.container-fluid > * { animation: fadeUp 0.35s ease both; }

/* Global HTMX progress bar: a thin accent line that fills across the top of
   the viewport whenever any HTMX request is in flight. */
#htmx-progress {
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, #6fb1ff, var(--accent));
  box-shadow: 0 0 10px rgba(47, 128, 237, 0.6);
  z-index: 3000; opacity: 0; transition: width 0.2s ease, opacity 0.3s ease;
}
body.htmx-busy #htmx-progress { opacity: 1; }

/* Tables: quieter header, gentle row hover */
.table-analytic thead th { border-bottom: 1px solid var(--card-border); }
.table-hover > tbody > tr { transition: background 0.12s ease; }

/* Status badges a touch softer */
.status-badge { letter-spacing: 0.2px; }

/* Inline SVG icons: inherit text colour, align with the text baseline */
.icon { display: inline-block; vertical-align: -0.18em; flex-shrink: 0; }
.nav-link .icon, .bosh-tab .icon, .dropdown-item .icon, .sys-link .icon { vertical-align: -0.22em; }

/* Role-coloured navbar avatar (user = blue default, admin = violet, super = gold) */
.avatar-circle.role-admin { background: linear-gradient(135deg, #8a6cff, #5b3fd6); }
.avatar-circle.role-super { background: linear-gradient(135deg, #f6c453, #e0a020); color: #3a2c00; }

/* Sticky navbar keeps a crisp edge while content scrolls under it */
.app-navbar.sticky-top { z-index: 1030; }

/* Section content dims briefly while its HTMX filter request is in flight */
.hx-fade { transition: opacity 0.2s ease; }
.hx-fade.htmx-request { opacity: 0.45; pointer-events: none; }

/* ============================ LOADING OVERLAY ============================ */
/* Any region wrapped in .loading-host shows a modern animated loader over its
   content while an HTMX request that targets it is in flight (JS toggles
   .is-loading). The content underneath is dimmed, never removed, so layout
   doesn't jump. */
.loading-host { position: relative; }
.app-loader {
  position: absolute; inset: 0; z-index: 6;
  display: none; align-items: center; justify-content: center;
  /* Fully opaque so the chart/table is HIDDEN behind the loader while data
     is being fetched, replaced by the animation rather than just dimmed. */
  background: var(--surface);
  border-radius: 14px;
  animation: loaderFade 0.15s ease;
}
/* Centred geometrically within its own box, including compact side cards. */
.app-loader-inner {
  position: static;
  height: fit-content;
  margin: auto;
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  padding: 1.5rem 0;
}
.loading-host.is-loading > .app-loader { display: flex; }
@keyframes loaderFade { from { opacity: 0; } to { opacity: 1; } }

/* 3x3 ripple loader, adapted to the product palette and compact card sizes
   from Uiverse/alexruix's "fluffy-starfish-52" loader (MIT). */
.ripple-loader {
  --ripple-cell: 17px;
  --ripple-gap: 2px;
  display: grid;
  grid-template-columns: repeat(3, var(--ripple-cell));
  grid-auto-rows: var(--ripple-cell);
  gap: var(--ripple-gap);
  width: calc(3 * var(--ripple-cell) + 2 * var(--ripple-gap));
  height: calc(3 * var(--ripple-cell) + 2 * var(--ripple-gap));
}
.ripple-cell {
  display: block; width: var(--ripple-cell); height: var(--ripple-cell);
  border-radius: 5px; background: transparent;
  animation: rippleCell 1.5s ease infinite;
}
.ripple-cell.d-1 { animation-delay: 100ms; }
.ripple-cell.d-2 { animation-delay: 200ms; }
.ripple-cell.d-3 { animation-delay: 300ms; }
.ripple-cell.d-4 { animation-delay: 400ms; }
.ripple-cell:nth-child(1) { --cell-color: #2f80ed; }
.ripple-cell:nth-child(2) { --cell-color: #3489ef; }
.ripple-cell:nth-child(3) { --cell-color: #3992f1; }
.ripple-cell:nth-child(4) { --cell-color: #3e9bf2; }
.ripple-cell:nth-child(5) { --cell-color: #43a4f2; }
.ripple-cell:nth-child(6) { --cell-color: #48adf2; }
.ripple-cell:nth-child(7) { --cell-color: #4db6f2; }
.ripple-cell:nth-child(8) { --cell-color: #52bff2; }
.ripple-cell:nth-child(9) { --cell-color: #56ccf2; }
@keyframes rippleCell {
  0%, 100% { background-color: transparent; transform: scale(.72); opacity: .28; }
  30% { background-color: var(--cell-color); transform: scale(1); opacity: 1; }
  60% { background-color: transparent; transform: scale(.82); opacity: .42; }
}
.loader-text { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); letter-spacing: 0.3px; }

/* Management navigation swaps #bosh-body, but each data card owns its loader.
   Compact cards use a smaller ripple so the animation remains inside the box. */
.bosh-shell .kpi-card .app-loader-inner,
.bosh-shell .bosh-card .app-loader-inner {
  gap: .38rem;
  padding: .35rem 0;
}
.bosh-shell .kpi-card .ripple-loader,
.bosh-shell .bosh-card .ripple-loader {
  --ripple-cell: 9px;
  --ripple-gap: 1px;
}
.bosh-shell .kpi-card .loader-text,
.bosh-shell .bosh-card .loader-text {
  font-size: .64rem;
}
.management-data-box {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 13px;
  background: var(--surface);
}

#bosh-content,
#sys-content {
  position: relative;
  min-height: 0;
}
#bosh-content {
  flex: 1 1 auto;
}

.role-change-form {
  width: 248px;
  padding: 5px 4px 4px;
}
.role-change-title {
  display: block;
  margin: 0 0 7px 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .45px;
  text-transform: uppercase;
}
.role-radio-group {
  display: grid;
  gap: 4px;
  margin-bottom: 9px;
  padding: 7px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-2) 86%, transparent);
}
.role-radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 5px 7px;
  border-radius: 9px;
  cursor: pointer;
  user-select: none;
  transition: background .22s var(--ease), transform .22s var(--ease);
}
.role-radio-label:hover {
  background: var(--surface);
  transform: translateX(2px);
}
.role-radio-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.role-radio-custom {
  position: relative;
  display: grid;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease);
}
.role-radio-custom::before {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--role-color, var(--accent));
  content: "";
  transform: scale(0);
  transition: transform .3s cubic-bezier(.2,1.45,.4,1);
}
.role-radio-custom::after {
  position: absolute;
  inset: -6px;
  border: 1.5px solid transparent;
  border-top-color: var(--role-color, var(--accent));
  border-radius: 50%;
  content: "";
  opacity: 0;
}
.role-radio-input:checked + .role-radio-custom {
  border-color: var(--role-color, var(--accent));
  transform: scale(.92);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--role-color, var(--accent)) 12%, transparent);
}
.role-radio-input:checked + .role-radio-custom::before { transform: scale(1); }
.role-radio-input:checked + .role-radio-custom::after {
  opacity: .7;
  animation: roleOrbit 2.6s linear infinite;
}
.role-radio-input:focus-visible + .role-radio-custom {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.role-radio-text {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 550;
  transition: color .2s var(--ease), font-weight .2s var(--ease);
}
.role-radio-input:checked ~ .role-radio-text { color: var(--text); font-weight: 700; }
.role-radio-admin { --role-color: #2f80ed; }
.role-radio-super_admin { --role-color: #9b51e0; }
.role-radio-user { --role-color: #27ae60; }
@keyframes roleOrbit { to { transform: rotate(360deg); } }

/* ===================== UMUMIY — OEC USLUBIDAGI REDIZAYN =====================
   Figma "Umumiy — Redesign v1" ekraniga aynan mos (o'lchamlar/ranglar). */

/* Sarlavha qatori: chapda nom+izoh, o'ngda davr + oqim + yuklab olish */
.u-head { margin-bottom: 14px; min-height: 40px; }
.u-title { font-size: 24px; font-weight: 700; color: var(--text); margin: 0; line-height: 1.2; }
.u-sub { font-size: 13.5px; color: var(--text-muted); margin-top: 4px; }
.u-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.davr-control { position:relative; width:220px; height:40px; }
.davr-control .davr-label { position:absolute; z-index:2; top:4px; left:12px; color:var(--text-muted); font-size:8px; font-weight:700; letter-spacing:.55px; pointer-events:none; }
.davr-control .fancy-period { display:block; width:100%; }
.davr-control .fancy-period .fancy-select-btn { height:40px; padding:14px 11px 3px; border-radius:10px; font-size:12.5px; font-weight:650; box-shadow:0 3px 12px rgba(16,32,58,.05); }
.davr-control .fancy-period .fancy-select-menu { width:100%; max-width:none; max-height:320px; padding:7px; }
.davr-control .fancy-period .fancy-option { padding-top:.52rem; padding-bottom:.52rem; }

.flow-seg {
  display: inline-flex; height: 40px; border: 1px solid var(--card-border);
  border-radius: 10px; background: var(--surface); overflow: hidden;
}
.flow-seg .seg {
  display: inline-flex; align-items: center; padding: 0 18px; border: 0; background: transparent;
  font-size: 12.5px; font-weight: 500; color: var(--text-muted); cursor: pointer; text-decoration: none;
}
.flow-seg .seg + .seg { border-left: 1px solid var(--card-border); }
.flow-seg .seg.active { background: var(--accent); color: #fff; font-weight: 600; }

.u-download {
  height: 40px; border-radius: 10px; display: inline-flex; align-items: center; gap: 8px;
  padding: 0 18px; font-size: 13.5px; font-weight: 600; color: #fff;
  background: var(--accent); border: 0; text-decoration: none;
  box-shadow: 0 4px 12px rgba(47, 128, 237, 0.28);
}
.u-download:hover { color: #fff; }

/* KPI kartalari: chap rangli chiziq + katta qiymat + delta chip + sparkline */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-fig {
  position: relative; background: var(--surface); border: 1px solid var(--card-border);
  border-radius: 16px; box-shadow: 0 6px 22px rgba(16, 32, 58, 0.07);
  padding: 17px 20px 15px 20px; min-height: 122px; overflow: hidden;
}
.kpi-fig::after { content:""; position:absolute; width:110px; height:110px; right:-42px; top:-48px; border-radius:50%; background:color-mix(in srgb, var(--spark) 10%, transparent); }
.kpi-fig .kpi-accent { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--spark, var(--accent)); }
.kpi-fig .kpi-label { font-size: 10.5px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.5px; }
.kpi-fig .kpi-value { font-size: 30px; font-weight: 700; color: var(--text); line-height: 1.15; margin-top: 2px; }
.kpi-fig .kpi-value.neg { color: #ce2a20; }
.kpi-fig .kpi-unit { font-size: 12px; font-weight: 500; color: var(--text-muted); margin-left: 6px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; padding-top: 8px; border-top: 1px solid color-mix(in srgb, var(--card-border) 70%, transparent); max-width: calc(100% - 74px); }
.kpi-delta {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.kpi-delta.up { background: #dcf2e3; color: #157347; }
.kpi-delta.down { background: #fbe0de; color: #ce2a20; }
.kpi-note { font-size: 11px; color: var(--text-muted); }
.kpi-motion { position:absolute; z-index:1; right:18px; top:29px; width:62px; height:38px; color:var(--spark); }
.motion-export,.motion-import { display:flex; align-items:center; gap:5px; overflow:hidden; }
.motion-export span,.motion-import span { width:7px; height:7px; flex:none; border-radius:50%; background:currentColor; opacity:.2; animation:kpiParticle 1.8s ease-in-out infinite; }
.motion-export span:nth-child(2),.motion-import span:nth-child(3){animation-delay:.25s}.motion-export span:nth-child(3),.motion-import span:nth-child(2){animation-delay:.5s}
.kpi-motion b { font-size:24px; font-weight:500; line-height:1; }
.motion-import { flex-direction:row; }
@keyframes kpiParticle { 0%,100%{opacity:.18;transform:scale(.75)} 50%{opacity:1;transform:scale(1.15)} }
.motion-turnover { display:grid; align-content:center; gap:1px; }
.motion-turnover i { display:block; width:48px; font-style:normal; font-size:20px; line-height:14px; animation:tradeLane 1.9s ease-in-out infinite; }
.motion-turnover i:last-child { margin-left:10px; animation-delay:.45s; }
@keyframes tradeLane { 0%,100%{transform:translateX(-5px);opacity:.35} 50%{transform:translateX(5px);opacity:1} }
.motion-balance { display:flex; align-items:center; justify-content:center; gap:6px; font-size:17px; font-weight:700; }
.motion-balance i { width:2px; height:30px; background:currentColor; border-radius:2px; animation:balanceNeedle 2.2s ease-in-out infinite; transform-origin:center; }
.motion-balance span { animation:balancePulse 2.2s ease-in-out infinite; }.motion-balance span:last-child{animation-delay:1.1s}
@keyframes balanceNeedle { 0%,100%{transform:rotate(-8deg)} 50%{transform:rotate(8deg)} }
@keyframes balancePulse { 0%,100%{opacity:.35} 50%{opacity:1} }
@keyframes kpiValueIn { from { opacity:.3; transform:translateY(4px); } to { opacity:1; transform:none; } }
#overview-content.htmx-added .kpi-value,
#overview-content.htmx-added .kpi-foot { animation:kpiValueIn .28s var(--ease) both; }

/* Ikki ustunli asosiy qism (chap treemap 910 : o'ng 466) */
.u-main { display:grid; grid-template-columns:minmax(0,910fr) minmax(0,466fr); gap:16px; align-items:stretch; height:calc(100vh - 387px); min-height:0; }
.u-right { display:grid; grid-template-rows:322px minmax(0,1fr); gap:16px; min-height:0; }
@media (max-width: 1100px) { .u-main { grid-template-columns: 1fr; } }
/* On short laptop screens, Dynamics needs more vertical plotting room. Focus
   that view by smoothly folding the KPI strip; returning to Treemap/Map
   restores it. This keeps the overview scroll-free without reducing the line
   chart to a decorative sliver. */
@media (max-height: 800px) and (min-width: 1101px) {
  #overview-content .kpi-row {
    max-height: 136px;
    opacity: 1;
    transition: max-height .32s var(--ease), opacity .2s var(--ease), margin .32s var(--ease);
  }
  #overview-content:has(.hero-panel-dynamics:not([hidden])) .kpi-row {
    max-height: 0;
    margin-bottom: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
  }
  #overview-content:has(.hero-panel-dynamics:not([hidden])) .u-main {
    grid-template-columns: minmax(0, 1fr);
    height: calc(100vh - 234px);
    transition: height .32s var(--ease);
  }
  #overview-content:has(.hero-panel-dynamics:not([hidden])) .u-right {
    display: none;
  }
}

/* Vizualizatsiya kartasi (chap) */
.viz-card2 {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 18px;
  box-shadow: 0 4px 16px rgba(16, 32, 58, 0.05); padding: 22px 24px;
  display:flex; flex-direction:column; min-height:0;
}
.viz-card2 .vc-title { font-size: 17px; font-weight: 700; color: var(--text); }
.viz-card2 .vc-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.vc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 6px; }

/* Ko'rinish almashtirgichi (segmented pill) */
.vsw { display: inline-flex; height: 38px; background: var(--surface-2); border-radius: 10px; padding: 4px; }
.vsw .seg {
  display: inline-flex; align-items: center; gap: 6px; padding: 0 16px; border: 0; border-radius: 8px;
  background: transparent; font-size: 12.5px; font-weight: 500; color: var(--text-muted); cursor: pointer;
}
.vsw .seg.active { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 1px 4px rgba(16, 32, 58, 0.12); }

/* Ko'rsatkich toggle (Qiymat · Ulush · O'sish) */
.meas { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-muted); }
.meas .meas-lbl { font-weight: 500; }
.meas .m { cursor: pointer; }
.meas .m.active { color: var(--accent); font-weight: 600; }
.meas .sep { color: var(--card-border); }
.vc-dl { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--card-border);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); text-decoration: none; }

/* O'ng tarafdagi kartalar */
.side-card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 18px;
  box-shadow: 0 4px 16px rgba(16, 32, 58, 0.05); padding: 20px 22px;
}
.u-right > .side-card { min-height:0; overflow:hidden; }
.u-right > .side-card:last-child { display:flex; flex-direction:column; }
.side-card .sc-head { display: flex; justify-content: space-between; align-items: baseline; }
.side-card .sc-title { font-size: 15px; font-weight: 700; color: var(--text); }
.side-card .sc-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.side-card .sc-link { font-size: 12px; font-weight: 600; color: var(--accent); text-decoration: none; }
.mini-legend { display: inline-flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--text-muted); }
.mini-legend .lg { display: inline-flex; align-items: center; gap: 5px; }
.mini-legend .dot { width: 9px; height: 9px; border-radius: 50%; }

/* Deskriptiv statistika: Figma'dagi 466 x 349 yon karta ritmida. */
.descriptive-card { display:flex; flex-direction:column; padding-top:14px; padding-bottom:12px; }
.descriptive-card .sc-head { align-items: flex-start; }
.descriptive-card .sc-title { margin: 0; line-height: 1.25; }
.ds-period {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 9px;
  border: 1px solid var(--card-border); border-radius: 7px; background: var(--surface-2);
  color: var(--text-muted); font-size: 10.5px; font-weight: 600; white-space: nowrap;
}
.ds-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); grid-template-rows:repeat(4,minmax(0,1fr)); flex:1 1 auto; gap:5px 8px; margin-top:8px; min-height:0; }
.ds-metric {
  min-width:0; min-height:46px; padding:5px 9px; border:1px solid var(--card-border);
  border-radius: 10px; background: var(--surface-2);
}
.ds-metric-accent { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.ds-label { display: block; color: var(--text-muted); font-size: 10.5px; font-weight: 500; line-height: 1.25; }
.ds-value { display:inline-block; margin-top:3px; color:var(--text); font-size:15px; font-weight:700; line-height:1.05; }
.ds-value-name { display:block; max-width:100%; overflow:visible; white-space:normal; font-size:13px; line-height:1.1; }
.ds-metric-accent .ds-value { color: var(--accent); }
.ds-unit { margin-left: 4px; color: var(--text-muted); font-size: 9.5px; white-space: nowrap; }
.ds-distribution { margin-top: auto; padding-top: 15px; }
.ds-dist-head { display: flex; justify-content: space-between; color: var(--text-muted); font-size: 10.5px; font-weight: 600; }
.ds-scale { position: relative; height: 8px; margin: 9px 3px 7px; border-radius: 99px; background: var(--surface-2); }
.ds-range { position: absolute; top: 0; height: 8px; min-width: 4px; border-radius: 99px; background: #9dc6f8; }
.ds-median { position: absolute; top: -3px; width: 3px; height: 14px; border-radius: 3px; background: var(--accent); transform: translateX(-1px); }
.ds-scale-labels { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; color: var(--text); font-size: 10px; font-weight: 600; }
.ds-scale-labels span { min-width: 0; }
.ds-scale-labels span:not(:first-child) { text-align: right; }
.ds-scale-labels small { display: block; margin-bottom: 1px; color: var(--text-muted); font-size: 8.5px; font-weight: 500; }
.ds-insight { display:flex; gap:10px; align-items:flex-start; margin-top:auto; padding:12px; border-radius:10px; background:color-mix(in srgb, var(--accent) 7%, var(--surface)); color:var(--text-muted); }
.ds-insight-icon { flex:0 0 20px; width:20px; height:20px; display:grid; place-items:center; border-radius:50%; background:var(--accent); color:#fff; font-size:12px; font-weight:700; }
.ds-insight p { margin:0; font-size:11px; line-height:1.45; }
.ds-insight strong { color:var(--accent); }

/* OEC-uslubidagi treemap interaction layer. */
/* Ko'rinish almashtirgichi (Treemap/Xarita/Dinamika) endi sakramaydi — har safar
   yangi panel bir zumda yumshoq ko'tarilib kiradi (framer-motion'dagi
   AnimatePresence uslubi, faqat sof CSS bilan). Panel [hidden] orqali
   render daraxtidan butunlay chiqib ketgani uchun qayta ko'ringanda animatsiya
   har doim boshidan ishga tushadi. */
@keyframes panelIn { from { opacity: 0; transform: translateY(8px) scale(.992); } to { opacity: 1; transform: none; } }
@keyframes panelOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-5px) scale(.994); } }
.hero-view-stack { position:relative; flex:1 1 auto; min-height:0; overflow:hidden; }
.hero-panel { position:absolute; inset:0; min-height:0; transform-origin:50% 48%; }
.hero-panel:not([hidden]) {
  display:flex; min-height:0; flex-direction:column;
  animation: panelIn var(--dur-base) var(--ease) both;
}
.hero-panel.is-entering { z-index:2; animation:panelIn 420ms var(--ease) both; }
.hero-panel.is-leaving { z-index:1; pointer-events:none; animation:panelOut 260ms var(--ease) both; }
.hero-panel > .chart { flex:1 1 auto; height:100% !important; }
.tm-stage { position:relative; flex:1 1 auto; min-height:0; }
.tm-stage > .chart { position:absolute; inset:0; width:100%; height:100% !important; min-height:0 !important; }
.tm-back { align-self:flex-start; flex:0 0 32px; height:32px; margin:0 0 6px; padding:0 12px; border:1px solid var(--card-border); border-radius:9px; background:var(--surface-2); color:var(--text); font-size:11.5px; font-weight:600; box-shadow:0 2px 8px rgba(16,32,58,.08); }
.tm-detail { position:absolute; z-index:6; right:14px; bottom:14px; width:min(310px,calc(100% - 28px)); padding:16px; border:1px solid var(--card-border); border-radius:14px; background:color-mix(in srgb, var(--surface) 96%, transparent); box-shadow:0 16px 40px rgba(16,32,58,.2); backdrop-filter:blur(12px); }
/* Davlat plitkasiga bosilganda tafsilot paneli pastdan yumshoq ko'tarilib,
   biroz kattalashib chiqadi — bosilgan joydan "javob kelayotgandek" tuyuladi. */
@keyframes tmDetailIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
.tm-detail:not([hidden]) { animation: tmDetailIn var(--dur-base) var(--ease) both; }
.tm-detail-close { position:absolute; top:8px; right:10px; border:0; background:transparent; color:var(--text-muted); font-size:20px; }
.tm-detail-kicker { display:block; color:var(--text-muted); font-size:9.5px; text-transform:uppercase; letter-spacing:.5px; }
.tm-detail > strong { display:block; margin:2px 28px 12px 0; color:var(--text); font-size:17px; }
.tm-detail-grid { display:grid; grid-template-columns:1fr 1fr; gap:8px; }
.tm-detail-grid span { padding:8px; border-radius:8px; background:var(--surface-2); color:var(--text-muted); font-size:9.5px; }
.tm-detail-grid b { display:block; margin-top:3px; color:var(--text); font-size:11.5px; }
.tm-detail a { display:flex; justify-content:center; margin-top:10px; padding:9px; border-radius:8px; background:var(--accent); color:#fff; text-decoration:none; font-size:11.5px; font-weight:600; }
.tm-tooltip { min-width:225px; }
.tm-tooltip > strong { display:block; margin-bottom:7px; font-size:13px; }
.tm-tooltip > div { display:flex; justify-content:space-between; gap:18px; padding:3px 0; font-size:11px; }
.tm-tooltip > div span { color:#aebed0; }
.tm-tooltip small { display:block; margin-top:7px; padding-top:7px; border-top:1px solid rgba(255,255,255,.18); color:#c9d6e4; }
.tm-tooltip .up,.tm-detail .up { color:#28b46d; }.tm-tooltip .down,.tm-detail .down { color:#ff6b60; }
.tm-flag-wave {
  position:relative; display:inline-flex; width:25px; height:17px; margin-right:7px;
  align-items:center; justify-content:center; overflow:hidden; border-radius:3px;
  background:var(--surface-2); box-shadow:0 1px 4px rgba(16,32,58,.22);
  transform-origin:left center;
  animation:tmFlagWave 1.8s ease-in-out infinite;
}
.tm-flag-wave img { position:absolute; inset:0; width:100%; height:100%; object-fit:cover; z-index:1; }
.tm-flag-wave i { color:var(--text-muted); font-size:8px; font-style:normal; font-weight:800; letter-spacing:.3px; }
.map-tooltip-title { display:flex; align-items:center; margin-bottom:6px; }
@keyframes tmFlagWave {
  0%,100% { transform:perspective(18px) rotateY(-5deg) skewY(0deg); }
  50% { transform:perspective(18px) rotateY(16deg) skewY(-2deg); }
}

@media (prefers-reduced-motion: reduce) {
  .ripple-cell, .tm-flag-wave, .hero-panel:not([hidden]),
  .hero-panel.is-entering, .hero-panel.is-leaving { animation-duration:1ms !important; animation-iteration-count:1 !important; }
}

/* Top yo'nalishlar reytingi */
.toplist { display:grid; grid-template-rows:repeat(10,minmax(0,1fr)); flex:1 1 auto; margin-top:4px; min-height:0; }
/* Reyting qatorlari birma-bir, chapdan siljib kirib keladi — ro'yxat statik
   jadval emas, tirik natija bo'lib his etilsin. Har qator o'zining o'rniga
   qarab (--i, Django forloop.counter0 dan) biroz kechikadi. */
@keyframes tlRowIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.tl-row {
  display:grid; grid-template-columns:20px 1fr auto; align-items:center; gap:10px; padding:2px 0;
  animation: tlRowIn var(--dur-enter) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.tl-rank { font-size: 12px; font-weight: 700; color: var(--text-muted); text-align: center; }
.tl-name { font-size: 13px; line-height:1.15; font-weight: 600; color: var(--text); text-decoration: none; }
.tl-name:hover { color: var(--accent); }
.tl-bar { height:4px; border-radius:3px; background:#eef5ff; margin-top:3px; overflow:hidden; max-width:190px; }
.tl-bar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.tl-end { display: flex; align-items: center; gap: 14px; }
.tl-val { font-size: 13px; font-weight: 700; color: var(--text); text-align: right; }
.tl-val small { font-size: 10px; font-weight: 400; color: var(--text-muted); margin-left: 3px; }
.tl-pct { font-size: 11.5px; font-weight: 600; text-align: right; min-width: 52px; }
.tl-pct.up { color: #157347; } .tl-pct.down { color: #ce2a20; }

:root[data-theme="dark"] .tl-bar { background: var(--surface-2); }
:root[data-theme="dark"] .kpi-delta.up, :root[data-theme="dark"] .tl-pct.up { color: #56d38a; }
:root[data-theme="dark"] .kpi-delta.down, :root[data-theme="dark"] .kpi-value.neg, :root[data-theme="dark"] .tl-pct.down { color: #ff6b60; }

/* ========================= YAGONA MOTION TIZIMI =========================
   Bitta easing egri chizig'i va bitta davomiylik shkalasi — hover, bosish,
   tab almashishi, grafik morfi va sahifa kirishi bir tizim bo'lib his etilsin.
   Figma'dagi "Yagona motion tizimi" spetsifikatsiyasiga mos.
   -- Manba: 03 · Prototip — Morph animatsiya sahifasi. */
:root {
  --ease: cubic-bezier(0.22, 1, 0.36, 1);   /* ease-out, yumshoq */
  --dur-press: 90ms;    /* bosish — scale 0.97 */
  --dur-hover: 160ms;   /* hover — ko'tarilish + halqa */
  --dur-base: 240ms;    /* tab / menyu / segment almashishi */
  --dur-morph: 500ms;   /* treemap plitka, ustun, chiziq yangi qiymatga o'tishi */
  --dur-enter: 350ms;   /* karta / sahifa kirishi (fadeUp) */
}

/* Har bir interaktiv sirt bitta easing egri chizig'ini baham ko'radi */
.card, .btn, .kpi-card, .bosh-card, .bosh-tab, .sys-link, .dropdown-item,
.form-control, .form-select, .status-badge, .nav-link, .fancy-select-btn,
.dyn-mode-tile, .dyn-chip, .code-link, .fancy-option,
.table-hover > tbody > tr, .ft-chip, .ft-clear, .ft-multi-btn, .ft-multi-opt {
  transition-timing-function: var(--ease);
}

/* Yagona tugma qonuni: hover'da ko'tariladi, bosilganda tez qisqaradi */
.btn { transition-duration: var(--dur-hover); }
.btn:active { transform: scale(0.97); transition-duration: var(--dur-press); }

/* Sahifa/karta kirishi umumiy egri va davomiylikda */
main.container-fluid > * { animation: fadeUp var(--dur-enter) var(--ease) both; }

/* Xabar bloklari bir necha soniyadan keyin o'zi so'nadi (app.js) — Bootstrap'ning
   0.15s linear o'chishi o'rniga umumiy motion tizimidagi egri chiziq. */
.alert.fade { transition: opacity var(--dur-base) var(--ease); }

/* Harakatni kamaytirishni afzal ko'rgan foydalanuvchilarni hurmat qilamiz */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ===== FILTR PANELI (Tovarlar / Davlatlar) ===== */
.ft-row2 {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 0.6rem;
  margin-top: 0.6rem;
  border-top: 1px solid var(--card-border);
}
.ft-row2 #ft-q {
  flex: 1 1 220px;
  max-width: 320px;
}
.ft-row2 .ft-bound { flex: 0 0 90px; width: 90px; }
.ft-row2 .ft-top { flex: 0 0 auto; width: auto; min-width: 104px; }
.ft-chips {
  flex: 1 0 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  max-height: 0;
  margin-top: -4px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(-7px);
  transition:
    max-height 0.42s var(--ease),
    margin-top 0.42s var(--ease),
    opacity 0.24s var(--ease),
    transform 0.42s var(--ease);
}
.ft-chips.has-items {
  max-height: 74px;
  margin-top: 0;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0);
}
.ft-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0.25rem 0.4rem 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--tint-blue);
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  animation: fsFade var(--dur-hover) var(--ease);
}
.ft-chip button {
  display: inline-grid;
  place-items: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  line-height: 1;
  transition: opacity var(--dur-hover) var(--ease);
}
.ft-chip button:hover { opacity: 0.62; }
.ft-clear {
  padding: 0.2rem 0.35rem;
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  transition: color var(--dur-hover) var(--ease);
}
.ft-clear:hover { color: var(--accent); }
.ft-multi {
  position: relative;
}
.ft-multi-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 132px;
  padding: 0.3rem 0.6rem;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.3;
  transition: border-color var(--dur-hover) var(--ease),
              box-shadow var(--dur-hover) var(--ease),
              background var(--dur-hover) var(--ease);
}
.ft-multi-btn:hover { border-color: var(--accent); }
.ft-multi.open .ft-multi-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,128,237,0.15);
}
.ft-multi.open .fancy-select-caret {
  transform: rotate(180deg);
  color: var(--accent);
}
.ft-multi-menu {
  position: absolute;
  z-index: 50;
  top: calc(100% + 6px);
  left: 0;
  display: none;
  min-width: 100%;
  width: max-content;
  max-height: 264px;
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 14px 34px rgba(16,32,58,0.18), 0 3px 10px rgba(16,32,58,0.08);
}
.ft-multi.open .ft-multi-menu {
  display: block;
  animation: fsFade 0.14s ease;
}
.ft-multi-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.87rem;
  cursor: pointer;
  transition: background var(--dur-hover) var(--ease);
}
.ft-multi-opt:hover { background: var(--surface-2); }
.ft-multi-opt input { accent-color: var(--accent); }

/* ================== FIXED-VIEWPORT ANALYTICS WORKSPACES ==================
   Products, Countries and Rating keep the page itself still. Long result sets
   use the remaining card space, so their scroll area has no hard-coded height. */
body:has(.analytics-shell) {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body:has(.analytics-shell) > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-top: 12px !important;
  padding-bottom: 10px !important;
}
body:has(.analytics-shell) .app-footer {
  margin-top: 0;
  padding-top: 5px !important;
  padding-bottom: 6px !important;
  font-size: 10px;
}
.analytics-shell {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.analytics-page-head {
  position: relative;
  flex: 0 0 auto;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(210px, auto) 1fr auto;
  align-items: center;
  gap: 18px;
}
.analytics-eyebrow {
  display: block;
  margin-bottom: 1px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.analytics-page-head h1 {
  margin: 0;
  color: var(--text);
  font-size: clamp(20px, 1.5vw, 27px);
  font-weight: 760;
  line-height: 1.05;
  letter-spacing: -.03em;
}
.analytics-head-facts {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}
.analytics-head-facts > span {
  min-width: 84px;
  padding: 6px 10px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 84%, var(--tint-blue));
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}
.analytics-head-facts b {
  color: var(--text);
  font-size: 13px;
}
.analytics-head-facts .analytics-top-fact {
  max-width: 290px;
  display: grid;
  padding-block: 5px;
}
.analytics-top-fact small { font-size: 9px; }
.analytics-top-fact b {
  overflow: hidden;
  text-overflow: ellipsis;
}
.analytics-download {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #20a56c, #138153);
  box-shadow: 0 7px 18px rgba(30,142,62,.18);
  font-weight: 700;
}
.analytics-download-compact {
  width: auto;
  min-width: 0;
  min-height: 34px;
  padding: 0.38rem 0.72rem;
  flex: 0 0 auto;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(30,142,62,.16);
}
.overview-download {
  align-self: center;
  text-decoration: none;
}
.analytics-download svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: downloadNudge 2.4s var(--ease) infinite;
}
@keyframes downloadNudge {
  0%, 72%, 100% { transform: translateY(0); }
  82% { transform: translateY(2px); }
  90% { transform: translateY(-1px); }
}
.analytics-filter {
  position: relative;
  z-index: 12;
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 10px 14px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 2px 9px rgba(16,30,54,.04);
}
.analytics-filter .filter-field {
  display: grid;
  gap: 3px;
  flex: 0 0 auto;
}
.analytics-filter .filter-field > label {
  margin: 0 0 0 2px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.analytics-filter .filter-field > .form-select { min-width: 156px; }
.analytics-filter .filter-level > .form-select { min-width: 190px; }
.analytics-filter .ft-row2 {
  flex: 1 1 580px;
  min-width: 0;
  padding: 14px 0 0;
  margin: 0;
  border: 0;
  align-self: flex-start;
  gap: 7px;
}
.analytics-shell:not(.view-table) .analytics-filter .ft-row2 {
  display: none;
}
.analytics-filter .ft-row2 .ft-chips {
  position: static;
  flex: 1 0 100%;
  width: 100%;
  padding: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.filter-search {
  position: relative;
  flex: 1 1 190px;
  min-width: 150px;
}
.filter-search svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 9px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}
.filter-search #ft-q {
  width: 100%;
  max-width: none;
  padding-left: 30px;
}
.analytics-crumb {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
  padding: 2px 7px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
}
.analytics-crumb a { text-decoration: none; }
.analytics-crumb b {
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
}
.analytics-workspace {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 10px 32px rgba(16,30,54,.07);
}
.workspace-head {
  flex: 0 0 auto;
  min-height: 59px;
  display: grid;
  grid-template-columns: minmax(170px, auto) auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--card-border);
}
.workspace-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
}
.workspace-live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2db36e;
  box-shadow: 0 0 0 0 rgba(45,179,110,.35);
  animation: livePulse 2s ease-out infinite;
}
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(45,179,110,.38); }
  65%, 100% { box-shadow: 0 0 0 7px rgba(45,179,110,0); }
}
.workspace-head h2 {
  margin: 1px 0 0;
  font-size: 15px;
  font-weight: 750;
}
.workspace-tabs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--card-border);
  border-radius: 11px;
  background: var(--surface-2);
}
.workspace-tabs button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 31px;
  padding: 5px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  transition: color var(--dur-base) var(--ease), background var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease), transform var(--dur-press) var(--ease);
}
.workspace-tabs button:hover { color: var(--accent); }
.workspace-tabs button:active { transform: scale(.96); }
.workspace-tabs button.active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 3px 10px rgba(16,30,54,.1);
}
.tab-glyph {
  width: 14px;
  height: 14px;
  display: inline-block;
  opacity: .9;
}
.tab-glyph-grid {
  background: conic-gradient(from 90deg at 47% 47%, transparent 0 25%, currentColor 0 50%, transparent 0 75%, currentColor 0);
  border: 1px solid currentColor;
  border-radius: 3px;
}
.tab-glyph-bars {
  background: linear-gradient(to top, currentColor 0 100%) 1px 9px/3px 5px no-repeat,
              linear-gradient(to top, currentColor 0 100%) 6px 4px/3px 10px no-repeat,
              linear-gradient(to top, currentColor 0 100%) 11px 7px/3px 7px no-repeat;
}
.tab-glyph-list {
  background: linear-gradient(currentColor,currentColor) 0 2px/14px 2px no-repeat,
              linear-gradient(currentColor,currentColor) 0 6px/14px 2px no-repeat,
              linear-gradient(currentColor,currentColor) 0 10px/14px 2px no-repeat;
}
.tab-glyph-orbit {
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 3px var(--surface-2);
}
.workspace-note {
  max-width: 560px;
  margin: 0;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.35;
}
.workspace-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}
.insight-panel {
  position: absolute;
  inset: 0;
  visibility: hidden;
  opacity: 0;
  transform: translateY(7px) scale(.997);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease),
              visibility 0s linear var(--dur-base);
}
.insight-panel.active {
  visibility: visible;
  opacity: 1;
  transform: none;
  pointer-events: auto;
  transition-delay: 0s;
}
.analytics-chart {
  width: 100%;
  height: 100%;
  min-height: 280px;
}
.insight-panel[data-insight-panel="compare"] {
  display: flex;
  flex-direction: column;
  padding: 7px 10px 4px;
}
.insight-panel[data-insight-panel="compare"] .analytics-chart {
  flex: 1 1 auto;
  min-height: 0;
}
.insight-table-panel {
  display: flex;
  flex-direction: column;
}
.table-panel-meta {
  flex: 0 0 auto;
  padding: 5px 13px;
  border-bottom: 1px solid var(--card-border);
  color: var(--text-muted);
  font-size: 10px;
}
.analytics-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 45%, transparent) transparent;
}
.analytics-table-scroll thead th {
  position: sticky;
  z-index: 3;
  top: 0;
}
.analytics-table-scroll .table-analytic { font-size: 12px; }
.analytics-table-scroll .table-analytic th,
.analytics-table-scroll .table-analytic td { padding-block: .4rem; }
.drill-link {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.drill-link span { transition: transform var(--dur-hover) var(--ease); }
.drill-link:hover span { transform: translateX(3px); }
.matrix-legend {
  position: absolute;
  z-index: 2;
  top: 9px;
  right: 12px;
  display: flex;
  gap: 9px;
  color: var(--text-muted);
  font-size: 9px;
}
.matrix-legend span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 50%;
}
.matrix-legend .up::before { background: #27ae60; }
.matrix-legend .down::before { background: #e4514f; }
.matrix-legend .size::before {
  border: 1px solid var(--accent);
  background: transparent;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 16%, transparent);
}

/* Rating: four lists share all remaining height and independently scroll. */
.rating-shell { gap: 10px; }
.rating-filter { flex-wrap: nowrap; }
.rating-period {
  margin-left: auto;
  align-self: center;
  color: var(--text-muted);
  font-size: 10px;
}
.rating-signal {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: center;
  gap: 18px;
}
.rating-shell .analytics-page-head > .analytics-download {
  grid-column: 3;
  justify-self: end;
}
.rating-signal > span {
  display: flex;
  align-items: end;
  gap: 3px;
  height: 28px;
}
.rating-signal i {
  width: 5px;
  border-radius: 4px;
  animation: signalWave 1.8s var(--ease) infinite alternate;
}
.signal-up i { background: #32b978; }
.signal-down i { background: #e35d58; }
.rating-signal i:nth-child(1) { height: 8px; animation-delay: -1.2s; }
.rating-signal i:nth-child(2) { height: 16px; animation-delay: -.8s; }
.rating-signal i:nth-child(3) { height: 25px; animation-delay: -.4s; }
.signal-down { transform: scaleY(-1); }
@keyframes signalWave {
  from { opacity: .42; transform: scaleY(.7); }
  to { opacity: 1; transform: scaleY(1.08); }
}
.rating-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.rating-card {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 6px 22px rgba(16,30,54,.06);
}
.rating-card::before {
  content: "";
  position: absolute;
  z-index: 0;
  top: -50px;
  right: -45px;
  width: 125px;
  height: 125px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--rating-color) 10%, transparent);
  animation: ratingAura 5s ease-in-out infinite alternate;
}
.rating-card.is-up { --rating-color: #20a56c; }
.rating-card.is-down { --rating-color: #df554f; }
@keyframes ratingAura {
  to { transform: translate(-10px, 9px) scale(1.12); opacity: .55; }
}
.rating-card > header {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  min-height: 49px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--card-border);
}
.rating-icon {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: color-mix(in srgb, var(--rating-color) 13%, transparent);
  color: var(--rating-color);
  font-size: 16px;
  font-weight: 800;
}
.rating-card header span {
  display: block;
  color: var(--text-muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.rating-card header h2 {
  margin: 1px 0 0;
  font-size: 13px;
  font-weight: 750;
}
.rating-card header > b {
  min-width: 27px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}
.rating-list-scroll {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.rating-list-scroll thead th {
  position: sticky;
  z-index: 3;
  top: 0;
  padding: 4px 7px;
  font-size: 9px;
}
.rating-list-scroll tbody tr {
  position: relative;
  animation: ratingRowIn var(--dur-enter) var(--ease) both;
  animation-delay: calc(var(--i, 0) * 22ms);
}
.rating-list-scroll tbody tr::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 2px auto 2px 0;
  width: var(--impact, 0%);
  border-radius: 0 7px 7px 0;
  background: color-mix(in srgb, var(--rating-color) 6%, transparent);
  pointer-events: none;
}
@keyframes ratingRowIn {
  from { opacity: 0; transform: translateX(-7px); }
}
.rating-list-scroll td {
  position: relative;
  z-index: 1;
  padding: 4px 7px;
  border-color: color-mix(in srgb, var(--card-border) 72%, transparent);
  font-size: 10px;
}
.rating-list-scroll td:nth-child(2) { max-width: 310px; }
.rating-list-scroll td a {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px;
  color: var(--text);
  text-decoration: none;
}
.rating-list-scroll td a b { color: var(--accent); white-space: nowrap; }
.rating-list-scroll td a span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rating-list-scroll td.num small {
  display: block;
  color: var(--text-muted);
  font-size: 8px;
  font-weight: 500;
}

@media (max-width: 1050px), (max-height: 690px) {
  body:has(.analytics-shell) {
    height: auto;
    min-height: 100dvh;
    overflow-y: auto;
  }
  body:has(.analytics-shell) > main {
    min-height: 640px;
    overflow: visible;
  }
  .analytics-shell { min-height: 620px; }
  .analytics-head-facts { display: none; }
  .workspace-note { display: none; }
  .workspace-head { grid-template-columns: minmax(150px, auto) auto; }
}
@media (max-width: 760px) {
  .analytics-page-head { grid-template-columns: 1fr auto; }
  .analytics-filter { flex-wrap: wrap; }
  .analytics-filter .ft-row2 { flex-basis: 100%; }
  .rating-grid { grid-template-columns: 1fr; grid-template-rows: repeat(4, minmax(260px, auto)); }
  .rating-period, .rating-signal { display: none; }
  .workspace-tabs button { padding-inline: 7px; }
}

/* Multi-period report */
.report-page {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.report-page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.report-page-head h1 {
  margin: 1px 0 0;
  font-size: 25px;
  font-weight: 760;
  letter-spacing: -.03em;
}
.report-page-head p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 11px;
}
.report-filter {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: end;
  gap: 14px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--card-border);
  border-radius: 13px;
  background: var(--surface);
}
.report-filter .filter-field {
  display: grid;
  gap: 3px;
}
.report-filter .filter-field > label {
  margin-left: 2px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.report-filter .form-select { min-width: 165px; }
.report-years .ft-multi-btn { min-width: 170px; }
.report-years .ft-multi-menu {
  min-width: 170px;
  max-height: 320px;
}
.report-year-option {
  min-height: 36px;
  gap: 10px;
}
.year-check {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 22px;
  height: 22px;
  cursor: pointer;
  user-select: none;
}
.year-check input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  cursor: pointer;
}
.year-checkmark {
  position: relative;
  display: block;
  width: 1.3em;
  height: 1.3em;
  border: 1px solid color-mix(in srgb, var(--text-muted) 55%, transparent);
  border-radius: 50px;
  background: color-mix(in srgb, var(--surface-2) 88%, #000);
  transition:
    background 0.7s var(--ease),
    border-color 0.7s var(--ease),
    box-shadow 0.7s var(--ease),
    transform 0.25s var(--ease);
  --spread: 5px;
}
.year-check input:checked ~ .year-checkmark {
  border-color: #161922;
  background: #161922;
  box-shadow:
    -3px -3px var(--spread) 0 rgba(91,81,216,.24),
    0 -3px var(--spread) 0 rgba(131,58,180,.20),
    3px -3px var(--spread) 0 rgba(225,48,108,.18),
    3px 3px var(--spread) 0 rgba(247,119,55,.18),
    -3px 3px var(--spread) 0 rgba(255,220,128,.18);
}
.year-checkmark::after {
  content: "";
  position: absolute;
  left: 0.45em;
  top: 0.23em;
  display: none;
  width: 0.25em;
  height: 0.5em;
  border: solid #f0f0f0;
  border-width: 0 0.15em 0.15em 0;
  transform: rotate(45deg);
}
.year-check input:checked ~ .year-checkmark::after { display: block; }
.year-check input:focus-visible ~ .year-checkmark {
  outline: 3px solid rgba(47,128,237,.22);
  outline-offset: 2px;
}
.report-rule {
  margin-left: auto;
  align-self: center;
  padding: 7px 10px;
  border-radius: 9px;
  background: var(--tint-blue);
  color: var(--text-muted);
  font-size: 10px;
}
.report-rule b { color: var(--accent); }
.report-scroll {
  min-height: 0;
  max-height: none;
  flex: 1 1 auto;
  overflow: auto;
  scrollbar-width: thin;
}
.report-table-multi {
  width: max-content;
  min-width: 100%;
}
.report-table-multi thead th {
  position: sticky;
  z-index: 3;
  top: 0;
  vertical-align: middle;
  text-align: center;
}
.report-table-multi thead th:first-child {
  left: 0;
  z-index: 6;
  min-width: 390px;
  text-align: left;
  background: var(--surface-2);
  box-shadow: 1px 0 0 var(--card-border);
}
.report-table-multi tbody td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 390px;
  max-width: 520px;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--card-border);
}
.report-table-multi tbody tr.table-light td:first-child {
  background: var(--surface-2);
}
.report-table-multi thead th small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 500;
}
.report-table-multi td:not(:first-child),
.report-table-multi th:not(:first-child) { min-width: 120px; }

body:has(.report-page) {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body:has(.report-page) > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-top: 12px !important;
  padding-bottom: 8px !important;
}
body:has(.report-page) .app-footer {
  flex: 0 0 auto;
  margin-top: 0;
  padding-top: 4px !important;
  padding-bottom: 5px !important;
  font-size: 10px;
}
body:has(.report-page) .report-page {
  height: 100%;
  min-height: 0;
}
.report-page-head,
.report-filter { flex: 0 0 auto; }
.report-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Fixed management lists: the browser page remains still while only the data
   region scrolls. This keeps navigation and filtering controls continuously
   available even with thousands of reference or trade rows. */
body:has(.manage-fixed-page) {
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
body:has(.manage-fixed-page) > main {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  padding-top: 12px !important;
  padding-bottom: 7px !important;
}
body:has(.manage-fixed-page) .app-footer {
  flex: 0 0 auto;
  margin-top: 0;
  padding-top: 4px !important;
  padding-bottom: 5px !important;
  font-size: 10px;
}
body:has(.manage-fixed-page) .bosh-shell,
body:has(.manage-fixed-page) .bosh-shell > .bosh-frame,
body:has(.manage-fixed-page) #bosh-body,
body:has(.manage-fixed-page) #bosh-content,
body:has(.manage-fixed-page) #sys-content {
  height: 100%;
  min-height: 0;
}
body:has(.manage-fixed-page) .bosh-shell,
body:has(.manage-fixed-page) .bosh-shell > .bosh-frame,
body:has(.manage-fixed-page) #bosh-body,
body:has(.manage-fixed-page) #bosh-content,
body:has(.manage-fixed-page) #sys-content {
  display: flex;
  flex-direction: column;
}
body:has(.manage-fixed-page) .bosh-head,
body:has(.manage-fixed-page) .bosh-tabs,
body:has(.manage-fixed-page) .sys-subnav {
  flex: 0 0 auto;
}
body:has(.manage-fixed-page) .bosh-head { margin-bottom: 8px !important; }
body:has(.manage-fixed-page) .bosh-tabs { margin-bottom: 8px !important; }
body:has(.manage-fixed-page) .sys-subnav { margin-bottom: 8px !important; }
.manage-fixed-page {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.manage-page-toolbar,
.manage-page-note {
  flex: 0 0 auto;
}
.manage-page-note { margin-bottom: 7px; }
.manage-fixed-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.manage-table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
}
.manage-table-scroll table { min-width: 880px; }
.manage-table-scroll thead th {
  position: sticky;
  z-index: 3;
  top: 0;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--card-border);
}
.manage-fixed-card > .border-top {
  flex: 0 0 auto;
  background: var(--surface);
}
.badge-replaced {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.format-guide-hint {
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 500;
}
.format-guide[open] .format-guide-hint::before { content: "Yopish"; }
.format-guide[open] .format-guide-hint { font-size: 0; }
.format-guide[open] .format-guide-hint::before { font-size: .72rem; }

@media (max-width: 850px) {
  .report-filter { flex-wrap: wrap; }
  .report-rule { flex-basis: 100%; margin-left: 0; }
}
:root[data-theme="dark"] .ft-chip { color: #7fb0ff; }
