/* ============================================================
   AFEX — Import-Eksport statistikasi bo'limi (WITS API)
   Sayt dizayn tizimiga mos: --brand #f20015, SF Pro, oq kartalar
   Barcha stillar .afx-wits ichida — saytga xavfsiz joylanadi
   ============================================================ */
.afx-wits {
  --aw-brand: #f20015;
  --aw-brand-soft: #fee2e5;
  --aw-ink: #17181c;
  --aw-text: #222;
  --aw-muted: #666;
  --aw-bg: #f8f8f8;
  --aw-surface: #fff;
  --aw-border: #e8e8e8;
  --aw-success: #009865;
  --aw-blue: #12233a;
  --aw-blue-soft: #dcebfb;
  --aw-shadow: 0 1px 2px #1118270f, 0 6px 20px #11182712;
  --aw-radius: 24px;
  font-family: sfPro, "sfPro Fallback", ui-sans-serif, -apple-system, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  color: var(--aw-text);
  background: var(--aw-bg);
  padding: 56px 16px 72px;
  line-height: 1.5;
  box-sizing: border-box;
}
.afx-wits *, .afx-wits *::before, .afx-wits *::after { box-sizing: border-box; }
.afx-wits .aw-container { max-width: 1200px; margin: 0 auto; }

/* ---------- Sarlavha ---------- */
.afx-wits .aw-head { text-align: left; margin-bottom: 28px; }
.afx-wits .aw-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--aw-ink); color: #fff;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  border-radius: 999px; padding: 7px 14px; margin-bottom: 14px;
}
.afx-wits .aw-badge .aw-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--aw-brand); }
.afx-wits h2.aw-title {
  font-size: clamp(26px, 4vw, 38px); font-weight: 700; color: var(--aw-ink);
  margin: 0 0 10px; line-height: 1.15; letter-spacing: -0.02em;
}
.afx-wits h2.aw-title .aw-red { color: var(--aw-brand); }
.afx-wits .aw-sub { color: var(--aw-muted); font-size: 15px; max-width: 640px; margin: 0; }

/* ---------- Filtr kartasi ---------- */
.afx-wits .aw-panel {
  background: var(--aw-surface); border-radius: var(--aw-radius);
  box-shadow: var(--aw-shadow); padding: 24px; margin-bottom: 20px;
}

/* Dataset tablari */
.afx-wits .aw-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.afx-wits .aw-tab {
  border: 1px solid var(--aw-border); background: #fff; color: var(--aw-text);
  border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all .18s ease; font-family: inherit;
}
.afx-wits .aw-tab:hover { border-color: #ccc; }
.afx-wits .aw-tab.is-active { background: var(--aw-ink); color: #fff; border-color: var(--aw-ink); }

/* Filtrlar to'ri */
.afx-wits .aw-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.afx-wits .aw-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.afx-wits .aw-label { font-size: 12px; font-weight: 600; color: var(--aw-muted); letter-spacing: .02em; }
.afx-wits .aw-label .aw-hint { font-weight: 400; color: #999; }

/* Combobox (qidiruvli tanlov) */
.afx-wits .aw-combo { position: relative; }
.afx-wits .aw-combo input[type="text"] {
  width: 100%; border: 1px solid var(--aw-border); border-radius: 14px;
  padding: 11px 36px 11px 14px; font-size: 14px; font-family: inherit;
  background: #fff; color: var(--aw-text); outline: none; transition: border .15s;
}
.afx-wits .aw-combo input[type="text"]:focus { border-color: var(--aw-brand); }
.afx-wits .aw-combo .aw-caret {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: #999; font-size: 11px;
}
.afx-wits .aw-drop {
  position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--aw-border); border-radius: 14px;
  box-shadow: 0 12px 32px #11182726; max-height: 280px; overflow-y: auto; display: none;
}
.afx-wits .aw-drop.is-open { display: block; }
.afx-wits .aw-opt {
  padding: 9px 14px; font-size: 14px; cursor: pointer; display: flex;
  justify-content: space-between; align-items: center; gap: 10px;
}
.afx-wits .aw-opt:hover, .afx-wits .aw-opt.is-hl { background: #f6f6f7; }
.afx-wits .aw-opt.is-sel { background: var(--aw-brand-soft); }
.afx-wits .aw-opt .aw-opt-code { font-size: 11px; color: #aaa; flex-shrink: 0; }
.afx-wits .aw-opt-group {
  padding: 8px 14px 4px; font-size: 10px; font-weight: 700; color: #999;
  text-transform: uppercase; letter-spacing: .08em;
}
.afx-wits .aw-empty-opt { padding: 12px 14px; color: #999; font-size: 13px; }

/* Chips — ko'p tanlov */
.afx-wits .aw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.afx-wits .aw-chips:empty { display: none; }
.afx-wits .aw-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--aw-ink); color: #fff; border-radius: 999px;
  padding: 5px 8px 5px 12px; font-size: 12px; font-weight: 500;
}
.afx-wits .aw-chip button {
  border: 0; background: #ffffff2b; color: #fff; border-radius: 50%;
  width: 16px; height: 16px; font-size: 10px; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
}
.afx-wits .aw-chip button:hover { background: var(--aw-brand); }

/* Segment (Eksport/Import, Ko'rinish, Tanlash usuli) */
.afx-wits .aw-seg {
  display: flex; width: 100%; background: var(--aw-bg);
  border: 1px solid var(--aw-border); border-radius: 999px;
  padding: 4px; gap: 4px;
}
.afx-wits .aw-seg button {
  flex: 1; min-width: 0; border: 0; background: transparent; border-radius: 999px;
  padding: 9px 10px; font-size: 13px; font-weight: 500; line-height: 1.2;
  color: var(--aw-muted); cursor: pointer; font-family: inherit;
  transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.afx-wits .aw-seg button:hover:not(.is-active) { color: var(--aw-ink); background: #ececee; }
.afx-wits .aw-seg button.is-active {
  background: #fff; color: var(--aw-ink); font-weight: 600;
  box-shadow: 0 1px 3px #11182726, 0 3px 10px #11182714;
}
.afx-wits .aw-seg button.is-active.aw-seg-x { color: var(--aw-success); }
.afx-wits .aw-seg button.is-active.aw-seg-m { color: var(--aw-brand); }

/* Select (yillar) */
.afx-wits select {
  border: 1px solid var(--aw-border); border-radius: 14px; padding: 11px 12px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--aw-text);
  outline: none; width: 100%; cursor: pointer;
}
.afx-wits select:focus { border-color: var(--aw-brand); }
.afx-wits .aw-years { display: flex; gap: 8px; align-items: center; }
.afx-wits .aw-years span { color: #999; font-size: 13px; }

/* Pastki qator: kengaytirilgan + tugma */
.afx-wits .aw-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-top: 20px; flex-wrap: wrap;
}
.afx-wits .aw-adv-toggle {
  border: 0; background: transparent; color: var(--aw-muted); font-size: 13px;
  font-weight: 500; cursor: pointer; display: inline-flex; align-items: center;
  gap: 6px; font-family: inherit; padding: 6px 0;
}
.afx-wits .aw-adv-toggle:hover { color: var(--aw-ink); }
.afx-wits .aw-adv-toggle .aw-arr { transition: transform .2s; font-size: 10px; }
.afx-wits .aw-adv-toggle.is-open .aw-arr { transform: rotate(180deg); }
.afx-wits .aw-btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--aw-brand); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 28px; font-size: 15px; font-weight: 500; cursor: pointer;
  font-family: inherit; transition: all .2s; box-shadow: 0 6px 18px #f2001540;
}
.afx-wits .aw-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 10px 24px #f2001555; }
.afx-wits .aw-btn:disabled { opacity: .6; cursor: wait; }
.afx-wits .aw-btn-ghost {
  background: #fff; color: var(--aw-ink); border: 1px solid var(--aw-border);
  box-shadow: none; padding: 10px 18px; font-size: 13px;
}
.afx-wits .aw-btn-ghost:hover:not(:disabled) { border-color: #bbb; box-shadow: none; }

/* Kengaytirilgan blok */
.afx-wits .aw-adv { display: none; border-top: 1px dashed var(--aw-border); margin-top: 18px; padding-top: 18px; }
.afx-wits .aw-adv.is-open { display: block; }
.afx-wits .aw-adv-note { font-size: 12px; color: #999; margin: 10px 0 0; }

/* Spinner */
.afx-wits .aw-spin {
  width: 16px; height: 16px; border: 2px solid #ffffff55; border-top-color: #fff;
  border-radius: 50%; animation: awspin .7s linear infinite; display: none;
}
.afx-wits .aw-btn.is-loading .aw-spin { display: inline-block; }
@keyframes awspin { to { transform: rotate(360deg); } }

/* Xabarlar */
.afx-wits .aw-msg {
  display: none; border-radius: 14px; padding: 13px 16px; font-size: 14px; margin-bottom: 20px;
}
.afx-wits .aw-msg.is-error { display: block; background: var(--aw-brand-soft); color: #a30010; }
.afx-wits .aw-msg.is-info { display: block; background: var(--aw-blue-soft); color: var(--aw-blue); }

/* ---------- Natijalar ---------- */
.afx-wits .aw-results { display: none; }
.afx-wits .aw-results.is-visible { display: block; }

/* KPI kartalari */
.afx-wits .aw-kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.afx-wits .aw-kpi {
  background: var(--aw-surface); border-radius: 20px; box-shadow: var(--aw-shadow);
  padding: 18px 20px;
}
.afx-wits .aw-kpi .aw-kpi-label {
  font-size: 12px; font-weight: 600; color: var(--aw-muted); display: flex;
  align-items: center; gap: 7px; margin-bottom: 8px;
}
.afx-wits .aw-kpi .aw-kpi-ic {
  width: 26px; height: 26px; border-radius: 9px; display: inline-flex;
  align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0;
}
.afx-wits .aw-kpi.aw-kpi-x .aw-kpi-ic { background: #d6f0e1; }
.afx-wits .aw-kpi.aw-kpi-m .aw-kpi-ic { background: var(--aw-brand-soft); }
.afx-wits .aw-kpi.aw-kpi-b .aw-kpi-ic { background: var(--aw-blue-soft); }
.afx-wits .aw-kpi .aw-kpi-value { font-size: 24px; font-weight: 700; color: var(--aw-ink); letter-spacing: -0.02em; }
.afx-wits .aw-kpi .aw-kpi-note { font-size: 12px; color: #999; margin-top: 4px; }
.afx-wits .aw-kpi .aw-kpi-note .up { color: var(--aw-success); font-weight: 600; }
.afx-wits .aw-kpi .aw-kpi-note .down { color: var(--aw-brand); font-weight: 600; }

/* Grafik kartasi */
.afx-wits .aw-chart-card {
  background: var(--aw-surface); border-radius: var(--aw-radius);
  box-shadow: var(--aw-shadow); padding: 22px 24px; margin-bottom: 20px;
}
.afx-wits .aw-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.afx-wits .aw-card-title { font-size: 16px; font-weight: 600; color: var(--aw-ink); margin: 0; }
.afx-wits .aw-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--aw-muted); }
.afx-wits .aw-legend .aw-leg { display: inline-flex; align-items: center; gap: 6px; }
.afx-wits .aw-legend .aw-leg i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.afx-wits .aw-chart-wrap { width: 100%; overflow-x: auto; }
.afx-wits .aw-chart-wrap svg { display: block; min-width: 480px; width: 100%; height: auto; }

/* Jadval kartasi */
.afx-wits .aw-table-card {
  background: var(--aw-surface); border-radius: var(--aw-radius);
  box-shadow: var(--aw-shadow); padding: 22px 24px;
}
.afx-wits .aw-table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--aw-border); }
.afx-wits table.aw-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
.afx-wits table.aw-table th {
  text-align: left; background: #fafafa; color: var(--aw-muted); font-weight: 600;
  font-size: 12px; letter-spacing: .03em; padding: 11px 14px; white-space: nowrap;
  border-bottom: 1px solid var(--aw-border); cursor: pointer; user-select: none;
}
.afx-wits table.aw-table th .aw-sort { color: #bbb; font-size: 10px; margin-left: 4px; }
.afx-wits table.aw-table th.is-sorted { color: var(--aw-ink); }
.afx-wits table.aw-table th.is-sorted .aw-sort { color: var(--aw-brand); }
.afx-wits table.aw-table td { padding: 11px 14px; border-bottom: 1px solid #f1f1f2; }
.afx-wits table.aw-table tbody tr:last-child td { border-bottom: 0; }
.afx-wits table.aw-table tbody tr:hover { background: #fafafa; }
.afx-wits table.aw-table td.aw-num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--aw-ink); white-space: nowrap; }
.afx-wits .aw-flag-x, .afx-wits .aw-flag-m {
  display: inline-block; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 3px 10px;
}
.afx-wits .aw-flag-x { background: #d6f0e1; color: #0c3b28; }
.afx-wits .aw-flag-m { background: var(--aw-brand-soft); color: #a30010; }
.afx-wits .aw-table-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 13px; color: var(--aw-muted);
}
.afx-wits .aw-table-foot .aw-foot-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* API so'rovi (texnik) */
.afx-wits details.aw-api {
  margin-top: 14px; font-size: 12.5px; color: var(--aw-muted);
}
.afx-wits details.aw-api summary { cursor: pointer; font-weight: 500; }
.afx-wits details.aw-api code {
  display: block; background: var(--aw-ink); color: #9fe8c3; border-radius: 12px;
  padding: 12px 14px; margin-top: 8px; overflow-x: auto; white-space: pre;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px;
}
.afx-wits .aw-src { font-size: 11.5px; color: #aaa; margin-top: 16px; }
.afx-wits .aw-src a { color: inherit; }

/* Skeleton yuklanish */
.afx-wits .aw-skeleton { display: none; }
.afx-wits .aw-skeleton.is-visible { display: block; }
.afx-wits .aw-sk-row {
  height: 68px; border-radius: 20px; margin-bottom: 14px;
  background: linear-gradient(90deg, #eee 25%, #f7f7f7 50%, #eee 75%);
  background-size: 200% 100%; animation: awsk 1.2s ease-in-out infinite;
}
.afx-wits .aw-sk-row.aw-sk-tall { height: 240px; }
@keyframes awsk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

@media (max-width: 640px) {
  .afx-wits { padding: 40px 12px 56px; }
  .afx-wits .aw-panel, .afx-wits .aw-chart-card, .afx-wits .aw-table-card { padding: 16px; }
  .afx-wits .aw-actions { flex-direction: column; align-items: stretch; }
  .afx-wits .aw-btn { justify-content: center; }
}


/* Auth-gate (WitsSection): mehmon uchun natijalar blur qilinadi */
.afx-wits-gated #aw-results{filter:blur(16px);pointer-events:none;user-select:none}


/* ---------- Yuklanish "teatri" (sun'iy kechiktirish paytidagi progress) ---------- */
.afx-wits .aw-progress {
  background: #fff; border: 1px solid #ececec; border-radius: 16px;
  padding: 18px 20px; margin: 2px 0 16px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.05);
}
.afx-wits .aw-progress-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px; font-size: 13.5px;
}
.afx-wits .aw-progress-txt { color: #555; transition: opacity 0.18s ease; min-height: 1.3em; }
.afx-wits .aw-progress-txt.is-swap { opacity: 0; }
.afx-wits .aw-progress-pct {
  font-weight: 700; color: var(--aw-brand); font-variant-numeric: tabular-nums;
  font-size: 14px; flex-shrink: 0;
}
.afx-wits .aw-progress-bar {
  height: 8px; border-radius: 99px; background: #f1f1f1; overflow: hidden;
}
.afx-wits .aw-progress-fill {
  display: block; height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, var(--aw-brand), #ff5a52);
  transition: width 0.15s ease; position: relative; overflow: hidden;
}
.afx-wits .aw-progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(255, 255, 255, 0.45) 50%, transparent 80%);
  background-size: 200% 100%;
  animation: aw-prog-shimmer 1.1s linear infinite;
}
@keyframes aw-prog-shimmer {
  from { background-position: 180% 0; }
  to { background-position: -80% 0; }
}

/* ------------------------------------------------------------------
   Telefon (≤640px): gorizontal skrol YO'Q (2026-10-06).
   Jadval "yorliq: qiymat" kartalariga aylanadi — yorliqlarni WitsSection.tsx
   dagi observeTableLabels() `data-label` qilib qo'yadi; sarlavha qatori
   saralash chiplari bo'lib qoladi. Grafik konteynerga siqiladi.
   ------------------------------------------------------------------ */
@media (max-width: 640px) {
  .afx-wits .aw-chart-wrap { overflow: visible; }
  .afx-wits .aw-chart-wrap svg { min-width: 0; }
  .afx-wits details.aw-api code { white-space: pre-wrap; word-break: break-all; overflow-x: visible; }

  .afx-wits .aw-table-wrap { overflow: visible; border: 0; border-radius: 0; }
  .afx-wits table.aw-table { min-width: 0; display: block; }
  .afx-wits table.aw-table thead { display: block; }
  .afx-wits table.aw-table thead tr { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 10px; }
  .afx-wits table.aw-table th {
    display: inline-flex; padding: 5px 10px; border: 1px solid var(--aw-border); border-radius: 999px;
    white-space: normal; background: transparent; letter-spacing: 0;
  }
  .afx-wits table.aw-table tbody { display: block; }
  .afx-wits table.aw-table tbody tr {
    display: block; padding: 10px 12px; margin-bottom: 8px;
    border: 1px solid var(--aw-border); border-radius: 14px;
  }
  .afx-wits table.aw-table td {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 3px 0; border: 0; text-align: right; white-space: normal; overflow-wrap: anywhere;
  }
  .afx-wits table.aw-table td.aw-num { white-space: normal; }
  .afx-wits table.aw-table td::before {
    content: attr(data-label); flex: 0 0 auto; max-width: 48%; text-align: left;
    font-size: 12px; font-weight: 500; color: var(--aw-muted);
  }
  .afx-wits table.aw-table td[data-label='']::before { display: none; }
  /* Bo'sh katak (masalan "Jahon jami" qatoridagi №) joy egallamasin */
  .afx-wits table.aw-table td:empty { display: none; }
}
