/* ============================================================
   Test Edu — umumiy dizayn tizimi (Purple Glass-morphism)
   Har ikkala sayt (user + admin) shu uslubdan foydalanadi.
   ============================================================ */

:root {
  /* Qarshi xalqaro universiteti brend rangi (logotipdagi toʻq siyohrang) */
  --brand: #7B2352;
  --violet-1: #7c3aed;
  --violet-2: #9333ea;
  --violet-3: #a855f7;
  /* Light mavzu: kartalar oq shishasimon, chegara nozik binafsha */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(124, 58, 237, 0.18);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --text: #241b3a;
  --muted: #6d6486;
  --ok: #059669;
  --err: #dc2626;
  --warn: #d97706;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

/* Yorug' (light) fon — nozik binafsha tovlanish */
body {
  background: linear-gradient(160deg, #f5f2fc 0%, #eee9f8 50%, #f7f4fd 100%);
  background-attachment: fixed;
}

/* Fon dekorativ "orb"lari — och binafsha yorugʻlik */
body::before, body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  z-index: 0;
  pointer-events: none;
}
body::before {
  width: 480px; height: 480px;
  background: #d6c9fb;
  top: -120px; left: -100px;
}
body::after {
  width: 520px; height: 520px;
  background: #cdd3fb;
  bottom: -160px; right: -120px;
}

/* ---------- Login: sekin harakatlanadigan blur shakllar (glass-morphism) ---------- */
#view-login { overflow: hidden; }               /* .layer => position:relative */
#view-login > .glass { position: relative; z-index: 2; }   /* karta shakllardan yuqorida */
.login-shapes { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.login-shapes span {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.5;
  mix-blend-mode: multiply;
  will-change: transform;
}
.login-shapes span:nth-child(1) {
  width: 320px; height: 320px; top: 6%; left: 8%;
  background: radial-gradient(circle at 35% 35%, #c9b6f7, transparent 68%);
  animation: floatA 26s ease-in-out infinite;
}
.login-shapes span:nth-child(2) {
  width: 380px; height: 380px; bottom: 4%; right: 6%;
  background: radial-gradient(circle at 40% 40%, #bcd0fb, transparent 68%);
  animation: floatB 32s ease-in-out infinite;
}
.login-shapes span:nth-child(3) {
  width: 260px; height: 260px; top: 42%; right: 26%;
  background: radial-gradient(circle at 40% 40%, #efc7ee, transparent 68%);
  animation: floatC 22s ease-in-out infinite;
}
.login-shapes span:nth-child(4) {
  width: 300px; height: 300px; bottom: 30%; left: 22%;
  background: radial-gradient(circle at 40% 40%, #b9ecdf, transparent 70%);
  animation: floatD 38s ease-in-out infinite;
}
@keyframes floatA {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(70px, 50px) scale(1.12); }
  66%      { transform: translate(-45px, 30px) scale(0.94); }
}
@keyframes floatB {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(-60px, -55px) scale(1.15); }
}
@keyframes floatC {
  0%, 100% { transform: translate(0, 0) scale(1); }
  40%      { transform: translate(55px, -40px) scale(0.9); }
  75%      { transform: translate(-30px, 45px) scale(1.1); }
}
@keyframes floatD {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50%      { transform: translate(50px, -60px) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  .login-shapes span { animation: none !important; }
}

/* ---------- Glass elementlar ---------- */
.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.12);
}
.glass-soft {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 16px;
}

/* Umumiy konteyner z-index (fon orblaridan ustun) */
.layer { position: relative; z-index: 1; }

/* ---------- Tugmalar ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
  font-size: 0.95rem;
}
.btn:hover { transform: translateY(-1px); background: rgba(124, 58, 237, 0.1); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--violet-2), var(--violet-1));
  border: none;
  color: #ffffff;                 /* purple fonda matn OQ boʻlishi shart */
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(124, 58, 237, 0.7); }
.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border: none;
  color: #ffffff;                 /* qizil fonda matn OQ */
}
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }

/* ---------- Inputlar ---------- */
.field {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border .2s, background .2s;
}
.field::placeholder { color: var(--muted); opacity: 0.8; }
.field:focus {
  border-color: var(--violet-2);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.18);
}
select.field option { color: #1e1b2e; }
/* Parol maydoni: nuqtalar bilan yashiriladi, lekin brauzer uni "password field"
   deb tanimaydi — shu sababli "parolni saqlaysizmi?" oynasi chiqmaydi.
   Qoʻllab-quvvatlamaydigan brauzerda common.js uni type=password ga qaytaradi. */
.field.pw-mask {
  -webkit-text-security: disc;
  text-security: disc;
  letter-spacing: 0.08em;
}
/* Parol koʻzchasi (show/hidden) */
.pw-wrap { position: relative; }
.pw-wrap .field { padding-right: 44px; }
.pw-eye {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; padding: 6px;
  color: var(--muted); display: inline-flex; align-items: center; border-radius: 8px;
}
.pw-eye:hover { color: var(--brand); background: rgba(124, 58, 237, 0.08); }
label.lbl { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }

/* Sana maydoni (KK.OO.YYYY) — notoʻgʻri yozilsa qizil ramka */
.dt-field { letter-spacing: 0.02em; }
.dt-field.dt-bad { border-color: var(--err); box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18); }

/* Sana maydoni + kalendar tugmasi (native date picker) yonma-yon */
.dt-wrap { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.dt-wrap .dt-field { flex: 1 1 auto; min-width: 0; }
/* Native date input — faqat kalendar tugmasi koʻrinadigan ixcham holatda */
.dt-wrap .dt-cal {
  width: 34px;
  min-width: 34px;
  padding: 6px 4px;
  border: 1px solid var(--field-border, rgba(124, 58, 237, 0.25));
  border-radius: 10px;
  background: var(--field-bg, rgba(255, 255, 255, 0.6));
  color: transparent;                 /* matnini yashiramiz, faqat ikonka qoladi */
  cursor: pointer;
}
.dt-wrap .dt-cal::-webkit-datetime-edit,
.dt-wrap .dt-cal::-webkit-inner-spin-button,
.dt-wrap .dt-cal::-webkit-clear-button { display: none; }
.dt-wrap .dt-cal::-webkit-calendar-picker-indicator {
  opacity: 0.75; cursor: pointer; margin: 0;
}
.dt-wrap .dt-cal:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Dashboard: koʻrsatkich kartochkasi va diagramma ---------- */
.stat { padding: 16px; border-radius: 14px; }
.stat .num { font-size: 1.9rem; font-weight: 800; color: var(--violet-1); line-height: 1.1; }

.chart { display: flex; flex-direction: column; gap: 8px; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: 0.8rem; color: var(--muted); margin-bottom: 4px;
}
.chart-legend .dot {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px;
}
.dot-1 { background: var(--violet-1); }
.dot-2 { background: #059669; }
.dot-3 { background: #f59e0b; }

.chart-row { display: flex; align-items: center; gap: 10px; }
.chart-label {
  flex: none; width: 190px; font-size: 0.85rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chart-bars { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.chart-bars .bar {
  height: 14px; border-radius: 4px; min-width: 26px;
  display: flex; align-items: center; justify-content: flex-end;
  padding-right: 5px; color: #fff; font-size: 0.7rem; font-weight: 700;
  transition: width .4s ease;
}
.bar.b1 { background: var(--violet-1); }
.bar.b2 { background: #059669; }
.bar.b3 { background: #f59e0b; }

@media (max-width: 640px) {
  .chart-label { width: 110px; font-size: 0.78rem; }
  .stat .num { font-size: 1.55rem; }
}

/* Saralanadigan ustun sarlavhasi */
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover { color: var(--violet-2); }
.tv-arrow { font-size: 0.8em; }

/* Sarlavha ostidagi ustun filtrlari va ommaviy amallar qatori */
tr.tv-filters th { padding-top: 0; padding-bottom: 8px; }
tr.tv-filters .field { font-size: 0.82rem; width: 100%; min-width: 70px; }
tr.tv-bulk th {
  padding-top: 8px; padding-bottom: 10px;
  background: rgba(124, 58, 237, 0.07);
  border-top: 1px solid rgba(124, 58, 237, 0.25);
  font-weight: 500;
}

/* ---------- Jadval ---------- */
/* Jadval oʻz ichida vertikal+gorizontal scroll boʻladi — shunда HEADER FREEZE ishlaydi
   (aks holда butun sahifa scroll boʻlib, sticky sarlavha «yopishmaydi»). */
.table-wrap { overflow: auto; max-height: 72vh; border-radius: 14px; }
/* Istalgan joyidan ushlab surish (drag-scroll) */
.table-wrap.dragging { cursor: grabbing; user-select: none; }
.table-wrap.dragging * { cursor: grabbing !important; }

/* Monitoring: Toʻgʻri / Xato yacheykalari toʻliq boʻyaladi.
   `table.tbl td` (text-align:left) dan ustun boʻlishi uchun selektor kuchliroq. */
table.tbl td.cell-ok, table.tbl td.cell-err, table.tbl td.cell-warn {
  color: #fff; font-weight: 700;
  text-align: center; vertical-align: middle;
}
td.cell-ok { background: rgba(16, 185, 129, 0.85); }
td.cell-err { background: rgba(239, 68, 68, 0.85); }
td.cell-warn { background: rgba(245, 158, 11, 0.9); }
/* Qator ustiga borganda ham rang saqlanadi */
table.tbl tr:hover td.cell-ok { background: rgba(16, 185, 129, 0.85); }
table.tbl tr:hover td.cell-err { background: rgba(239, 68, 68, 0.85); }
table.tbl tr:hover td.cell-warn { background: rgba(245, 158, 11, 0.9); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.tbl th, table.tbl td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(124, 58, 237, 0.12);
  white-space: nowrap;
}
table.tbl th {
  color: var(--muted); font-weight: 600;
  background: rgba(246, 243, 252, 0.99);   /* freeze paytida ostidagi qatorlar koʻrinmasin */
  z-index: 2;
}
/* Header FREEZE — butun thead (sarlavha + filtr qatori) yuqorида qotib turadi */
table.tbl thead { position: sticky; top: 0; z-index: 3; }
table.tbl tr:hover td { background: rgba(124, 58, 237, 0.06); }
/* Yacheykadagi bosiladigan son — link koʻrinishiga oʻtmaydi (oddiy son, pointer) */
.stat-drill { cursor: pointer; }
.stat-drill:hover { opacity: 0.75; }

/* Zip import: fan bazaga mos kelmadi — pulslanuvchi «mos emas» belgisi */
.zip-mismatch {
  display: inline-block; margin-left: 4px;
  padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700; color: #fff; background: #ef4444;
  animation: sessPulse 1.4s ease-in-out infinite;
}
/* Zip import: bir xil fan takrorlanganda ogohlantirish paneli */
.zip-dup {
  display: none; margin-bottom: 8px; padding: 7px 10px; border-radius: 10px;
  font-size: 0.8rem; font-weight: 600;
  color: #b45309; background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
}
.zip-dup.show { display: block; animation: sessPulse 1.6s ease-in-out infinite; }

/* «k ta aktiv sessiya» — header yonidagi pulslanuvchi ogohlantirish */
.sess-pulse {
  cursor: pointer; white-space: nowrap;
  padding: 4px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; color: #fff;
  background: #ef4444;
  animation: sessPulse 1.6s ease-in-out infinite;
}
@keyframes sessPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.55); }
  50% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
}

/* Drag-drop guruh tanlash (Tyutorlar kontingenti) */
.dnd-box {
  min-height: 64px; padding: 8px; border-radius: 12px;
  border: 1px dashed rgba(124, 58, 237, 0.3);
  background: rgba(250, 248, 255, 0.6);
  display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start;
}
.dnd-box.dnd-over { border-color: var(--violet-2); background: rgba(124, 58, 237, 0.08); }
.dnd-chip {
  padding: 4px 10px; border-radius: 999px; cursor: grab; user-select: none;
  background: linear-gradient(135deg, var(--violet-1), var(--violet-2)); color: #fff;
  font-size: 0.82rem; font-weight: 600;
}
.dnd-chip.dragging { opacity: 0.5; }
.dnd-zone .dnd-chip { background: linear-gradient(135deg, #10b981, #059669); }

/* Panel maydoni — butun ekran kengligiga yoyiladi (masshtab kichraytirilganda ham
   jadval boʻsh joy qoldirmasdan toʻliq yoyilib ketadi). */
.panel-wrap { max-width: 100%; width: 100%; }

/* Koʻp ustunli jadvallar: ixchamroq va uzun matnlar boʻgʻinlanadi.
   Birinchi ustun (F.I.SH.) yon tomonga skroll qilinganda ham joyida turadi. */
table.tbl.tbl-wide { font-size: 0.82rem; }
table.tbl.tbl-wide th, table.tbl.tbl-wide td { padding: 7px 8px; }
table.tbl.tbl-wide td.wrap, table.tbl.tbl-wide th.wrap {
  white-space: normal; min-width: 120px; max-width: 220px;
}
table.tbl.tbl-wide .field { font-size: 0.78rem; padding: 4px 6px; }

table.tbl.stick-1 th:first-child, table.tbl.stick-1 td:first-child {
  position: sticky; left: 0; z-index: 1;
  background: rgba(250, 248, 255, 0.98);
  box-shadow: 1px 0 0 rgba(124, 58, 237, 0.14);
}
table.tbl.stick-1 th:first-child { z-index: 3; }

/* KENG jadval (koʻp ustun) — 100% ga siqilmasin, oʻz .table-wrap ichida gorizontal
   scroll boʻlsin (aks holda telefonda ustunlar bir-birining ustiga tushib ketardi). */
table.tbl.tbl-wide { min-width: max-content; }

/* Fan nomi havolasi — TAG CHIZIGʻISIZ (chiroyli, bosiladigan rang) */
.fan-link { color: var(--violet-2); text-decoration: none; cursor: pointer; font-weight: 600; }
.fan-link:hover { color: var(--violet-1); }

/* Telefonda (kichik ekran) — birinchi ustunni «yopishtirmaymiz»: sticky ustun keng
   jadvalda boshqa kataklar ustiga tushib, tugmalarni xira/orqada koʻrsatardi. */
@media (max-width: 700px) {
  table.tbl.stick-1 th:first-child, table.tbl.stick-1 td:first-child {
    position: static; box-shadow: none; z-index: auto;
  }
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}
.badge-ok { background: rgba(52, 211, 153, 0.2); color: var(--ok); }
.badge-err { background: rgba(248, 113, 113, 0.2); color: var(--err); }
.badge-warn { background: rgba(251, 191, 36, 0.2); color: var(--warn); }
.badge-info { background: rgba(192, 132, 252, 0.2); color: var(--violet-3); }

.hidden { display: none !important; }
/* Token boʻlsa — sahifa yuklanishida login «chaqnamasligi» uchun (init() olib tashlaydi) */
html.te-authed #view-login { display: none !important; }
html.te-authed #view-panel { display: flex !important; }
html.te-authed #view-dash { display: block !important; }
.muted { color: var(--muted); }

/* ---------- Inline SVG ikonalar ---------- */
.icon {
  display: inline-block;
  vertical-align: -0.15em;
  flex: none;
}
/* Tugma/tab ichidagi ikonalar matn bilan tekis tursin (.btn allaqachon inline-flex) */
.btn .icon { margin: 0; }

/* Brend logo (login sahifasidagi katta ikona) — binafsha */
.brand-logo { color: var(--violet-1); line-height: 0; }
.brand-logo svg { display: inline-block; }

/* ---------- Universitet brendi (logotip va footer) ----------
   Logotip fayli (frontend/static/common/logo.png) — RASMIY nusxa, tegilmagan.
   Uning atrofida katta oq boʻshliq bor, shuning uchun faqat CSS bilan kerakli
   qismini koʻrsatamiz (fayl oʻzgartirilmaydi):
     toʻliq blok (belgi + yozuv): rasmda left 22.92%, top 32.69%, w 54.11%, h 34.54%
     faqat belgi (KXI):           rasmda left 22.92%, top 39.07%, w 15.73%, h 21.76% */
.brand-logo, .brand-logo-sm {
  line-height: 0;
  display: inline-block;
  overflow: hidden;          /* atrofdagi oq boʻshliq kesiladi */
  vertical-align: middle;
}

/* Kirish sahifasi — belgi + universitet nomi (toʻliq blok) */
.brand-logo { width: 280px; height: 101px; }
.brand-img {
  display: block;
  width: 517.5px;            /* 280 / 0.5411 */
  height: 291.1px;           /* nisbat saqlanadi: 1080/1920 */
  margin: -95.2px 0 0 -118.6px;
  max-width: none;
}

/* Sarlavha (header) — faqat kvadrat belgi (yozuvsiz).
   Fon SHAFFOF: orqadagi purple koʻrinadi; yuklangan PNG shaffofligi saqlanadi
   (oq quti boʻlmaydi). Har qanday logo buzilmasdan sigʻadi. */
.brand-logo-sm {
  width: 40px; height: 40px; flex: none;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.brand-img-sm {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-width: 100%;
}

@media (max-width: 640px) {
  .brand-logo { width: 210px; height: 76px; }
  .brand-img { width: 388.1px; height: 218.3px; margin: -71.4px 0 0 -88.9px; }
}

.site-footer {
  position: relative;
  z-index: 2;
  margin-top: 24px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(6px);
}
.site-footer b { color: var(--brand); font-weight: 700; }

/* Talaba sayti krediti — yuqorida (headerda) QOTIB turadi (scroll qilinsa ham).
   Barcha sahifada: login, dashboard, test yechish. */
.site-credit {
  position: fixed;
  top: max(6px, env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(80, 40, 160, 0.10);
  pointer-events: none;
  white-space: nowrap;
}
.site-credit b { color: var(--brand); font-weight: 700; }

/* ============================================================
   Custom Modal (Glass-morphism, backdrop blur) — brauzer alert OʻRNIGA
   ============================================================ */
#modal-root {
  position: fixed;
  inset: 0;
  /* Tahrirlash oynalari (#q-editor va h.k.) z-index 1050–1100; captcha/tasdiqlash
     oynasi ULARDAN USTUN turishi kerak (orqada qolmasin) */
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(46, 16, 101, 0.32);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
#modal-root.show { display: flex; animation: fadein .2s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Jadval filtrlanganda «Filtrlangan» soʻzi qizil pulse boʻlib yonib-oʻchadi */
.filtered-pulse {
  color: #dc2626;
  font-weight: 700;
  animation: filtered-blink 1s ease-in-out infinite;
}
@keyframes filtered-blink {
  0%, 100% { opacity: 1; text-shadow: 0 0 0 rgba(220, 38, 38, 0); }
  50% { opacity: 0.35; text-shadow: 0 0 6px rgba(220, 38, 38, 0.6); }
}

.modal-card {
  width: 100%;
  max-width: 440px;
  padding: 28px;
  text-align: center;
  animation: pop .25s cubic-bezier(.2, .9, .3, 1.2);
  /* Uzun xabar (100+ xato qatori) — karta ichida scroll boʻladi, «Yopish»
     tugmasi doim koʻrinib turadi */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-icon {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
}
.modal-icon.ok { background: rgba(52, 211, 153, 0.18); }
.modal-icon.err { background: rgba(248, 113, 113, 0.18); }
.modal-icon.warn { background: rgba(251, 191, 36, 0.18); }
.modal-icon.info { background: rgba(192, 132, 252, 0.18); }

.modal-title { font-size: 1.25rem; font-weight: 700; margin: 0 0 8px; flex: none; }
.modal-msg {
  color: var(--muted); margin: 0 0 22px; line-height: 1.5; white-space: pre-line;
  /* Uzun roʻyxat — shu yerda scroll boʻladi (tugmalar pastda koʻrinib turadi) */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  text-align: left;
}
.modal-icon { flex: none; }
.modal-actions { display: flex; gap: 10px; justify-content: center; flex: none; }
/* Kirish/kod soʻrash inputi ham qisqarmasin */
#modal-input { flex: none; }

/* ---------- Toggle Switch ----------
   Butun tizimdagi barcha checkboxʼlar avtomatik toggle switch koʻrinishiga oʻtadi. */
input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 42px;
  height: 23px;
  margin: 0;
  border-radius: 999px;
  background: rgba(120, 120, 140, 0.38);
  cursor: pointer;
  vertical-align: middle;
  transition: background .18s ease;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
  transition: transform .18s ease;
}
input[type="checkbox"]:checked { background: var(--brand); }
input[type="checkbox"]:checked::after { transform: translateX(19px); }
input[type="checkbox"]:indeterminate { background: var(--warn); }
input[type="checkbox"]:indeterminate::after { transform: translateX(9px); }
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
input[type="checkbox"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Yuklanish (kvadrat spinner) ----------
   Bazadan maʼlumot kutilayotganda uzluksiz aylanib turadigan KVADRAT animatsiya.
   Ochiq fonli kartalarda koʻrinishi uchun binafsha rangda; tugma ichida oq boʻladi. */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(124, 58, 237, 0.22);
  border-top-color: #7c3aed;
  border-radius: 4px;                       /* kvadrat (ozgina yumaloq burchak) */
  animation: spin .8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
/* Tugma ichidagi spinner — oq (binafsha tugma ustida koʻrinsin) */
.btn .spinner, .btn-primary .spinner, .btn-danger .spinner {
  border-color: rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}
/* Kattaroq markaziy yuklanish belgisi (jadval/karta oʻrtasida) */
.spinner-lg { width: 40px; height: 40px; border-width: 4px; border-radius: 7px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   HEADER — fonga nisbatan kontrast uchun PURPLE
   (faqat <header> elementlari; tablar/nav va boshqa .glass-soft
    kartalar yorug' boʻlib qoladi)
   ============================================================ */
header.glass-soft {
  background: linear-gradient(135deg, var(--violet-1), var(--violet-2));
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.35);
}
/* Header ichidagi matnlar oq/och rangda oʻqiladi */
header.glass-soft .muted { color: rgba(255, 255, 255, 0.85); }

/* Header logotipi — fon shaffof (oq quti/soya yoʻq), purple koʻrinib turadi. */

/* Header ichidagi badge — oq shishasimon */
header.glass-soft .badge {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff;
}

/* Header ichidagi oddiy tugma (masalan "Chiqish") — oq kontur */
header.glass-soft .btn {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
}
header.glass-soft .btn:hover { background: rgba(255, 255, 255, 0.3); }

/* Header ichidagi asosiy tugma ("Yakunlash") — purple fonda oq koʻzga tashlanadi */
header.glass-soft .btn-primary {
  background: #ffffff;
  color: var(--violet-1);
  box-shadow: none;
}
header.glass-soft .btn-primary:hover { background: rgba(255, 255, 255, 0.9); }

/* ============================================================
   MOBIL / RESPONSIVE — telefon va planshetlar uchun moslash
   ============================================================ */

/* Gorizontal skroll (fon orblari sabab) oldini olamiz.
   MUHIM: `overflow-x: hidden` html elementida `position: sticky` ni buzadi
   (sarlavha va savollar navigatori "yopishmay" qoladi). Zamonaviy brauzerlarda
   `clip` xuddi shu ishni qiladi, lekin skroll konteyneri yaratmaydi. */
html, body { overflow-x: hidden; max-width: 100%; }
@supports (overflow-x: clip) {
  html, body { overflow-x: clip; }
}

/* Har qanday jadval mobilda ham skroll bilan sigʻadi */
.table-wrap { -webkit-overflow-scrolling: touch; }

/* --- Planshet va undan kichik (≤768px) --- */
@media (max-width: 768px) {
  .glass { border-radius: 16px; }
  .panel-card { padding: 16px; }
  .q-card { padding: 16px; }
  /* Formadagi ustunlar bitta ustunga tushadi */
  .grid-form { grid-template-columns: 1fr; }
}

/* --- Telefon (≤640px) --- */
@media (max-width: 640px) {
  /* Fon orblarini kichraytiramiz — ortiqcha overflow va sekinlashuvni oldini oladi */
  body::before { width: 260px; height: 260px; top: -80px; left: -80px; filter: blur(70px); }
  body::after  { width: 280px; height: 280px; bottom: -100px; right: -80px; filter: blur(70px); }

  /* Ichki boʻshliqlarni kichraytiramiz */
  .glass { border-radius: 14px; }
  .panel-card { padding: 14px; }
  .q-card { padding: 14px; }

  /* Sarlavha (header) — kontent sigʻmasa yangi qatorga oʻtsin */
  header.glass-soft {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 14px !important;
    margin: 10px !important;
  }

  /* Tugmalar mobilda biroz ixchamroq, matni sigʻsin */
  .btn { padding: 9px 14px; font-size: 0.9rem; }
  .btn-sm { padding: 6px 10px; font-size: 0.8rem; }

  /* Tablar chapdan skroll qilinadi, siqilmaydi */
  #tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #tabs .tab-btn, #tabs .btn { flex: none; white-space: nowrap; }

  /* Jadval matni kichrayadi */
  table.tbl { font-size: 0.82rem; }
  table.tbl th, table.tbl td { padding: 8px 9px; }

  /* Modal ekranga moslashadi */
  .modal-card { padding: 20px; }
  .modal-actions { flex-direction: column; }
  .modal-actions .btn { width: 100%; }

  /* Test sahifasidagi savol matni va variantlar */
  .q-text { font-size: 1rem; }
  .opt { padding: 11px 12px; gap: 10px; }

  /* Kirish (login) kartasi toʻliq kenglikda, chetlari nafas olsin */
  #view-login { padding: 16px !important; }
}

/* --- Juda kichik telefonlar (≤400px) --- */
@media (max-width: 400px) {
  h1 { font-size: 1.4rem; }
  .stat .num { font-size: 1.5rem; }
}

/* Sensorli qurilmalarda hover "yopishib qolish"ini oldini olamiz */
@media (hover: none) {
  .btn:hover { transform: none; }
  .subject-card:hover { transform: none; }
}
