:root {
  --bg: #f3f6f4; --bg2: #e8efe9; --card: #ffffff; --ink: #17212b; --muted: #5d6b78; --line: #dce3de;
  --brand: #0b6e4f; --brand-2: #12936a; --brand-ink: #ffffff; --brand-soft: #e2f3eb;
  --good: #1b7f3b; --good-soft: #e4f5e9; --good-line: #bfe3c8;
  --bad: #c0392b; --bad-soft: #fbe9e7; --bad-line: #f2c2bb;
  --warn: #a86a10; --warn-soft: #fdf3e0; --warn-line: #f1dcb0;
  --key: #ffffff; --radius: 14px;
  --shadow: 0 1px 2px rgba(16,40,30,.05), 0 6px 20px rgba(16,40,30,.06);
  --shadow-lg: 0 2px 4px rgba(16,40,30,.06), 0 14px 34px rgba(16,40,30,.12);
  --hero: linear-gradient(135deg, #0b6e4f 0%, #12936a 55%, #2bb38a 100%);
}
[data-theme="dark"] {
  --bg: #0f1614; --bg2: #141d1a; --card: #18221f; --ink: #e7efeb; --muted: #9aaba3; --line: #2a3833;
  --brand: #2fbf8f; --brand-2: #46d3a4; --brand-ink: #06231a; --brand-soft: #173329;
  --good: #5ed488; --good-soft: #15301f; --good-line: #25553a;
  --bad: #ff8a7a; --bad-soft: #3a1c18; --bad-line: #6a2f28;
  --warn: #f2c063; --warn-soft: #33290f; --warn-line: #5c4a1c;
  --key: #101815;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  --shadow-lg: 0 2px 4px rgba(0,0,0,.35), 0 14px 34px rgba(0,0,0,.4);
  --hero: linear-gradient(135deg, #0d3b2c 0%, #125a43 55%, #17755a 100%);
}
* { box-sizing: border-box; }
html { color-scheme: light; } html[data-theme="dark"] { color-scheme: dark; }
html, body { margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); line-height: 1.5; font-size: 16px; transition: background-color .25s, color .25s; }
a { color: var(--brand); }
.container { max-width: 920px; margin: 0 auto; padding: 16px; }

/* header */
header.top { background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
header.top .container { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.logo { font-weight: 800; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 8px; letter-spacing: -.01em; }
.logo .logo-img { height: 36px; width: auto; display: block; }
.logo .logo-dark { display: none; }
[data-theme="dark"] .logo .logo-light { display: none; }
[data-theme="dark"] .logo .logo-dark { display: block; }
.logo .logo-mark { width: 30px; height: 30px; display: block; }
@media (max-width: 520px) { .logo .logo-img { height: 30px; } }
.logo span.badge { background: var(--brand-soft); color: var(--brand); border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 700; }
.head-right { display: flex; align-items: center; gap: 6px; }
nav { display: flex; gap: 2px; }
nav a { text-decoration: none; color: var(--muted); font-size: 15px; padding: 7px 11px; border-radius: 9px; font-weight: 600; transition: background .15s, color .15s; }
nav a:hover { color: var(--brand); background: var(--brand-soft); }
nav a.active { color: var(--brand); background: var(--brand-soft); }
.icon-btn { height: 38px; min-width: 38px; padding: 0 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-weight: 700; font-size: 13px; transition: transform .15s, border-color .15s; }
.icon-btn:hover { border-color: var(--brand); transform: translateY(-1px); }
.icon-btn svg { width: 18px; height: 18px; }
#themeBtn svg { transition: transform .4s; } #themeBtn:hover svg { transform: rotate(25deg); }
.lang { position: relative; }
.lang-menu { position: absolute; right: 0; top: 44px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 170px; animation: pop .14s ease-out; z-index: 50; }
.lang-menu button { display: flex; width: 100%; justify-content: space-between; gap: 10px; padding: 9px 11px; border: 0; background: none; color: var(--ink); font: inherit; border-radius: 8px; cursor: pointer; text-align: left; }
.lang-menu button:hover { background: var(--brand-soft); }
.lang-menu button.on { color: var(--brand); font-weight: 700; }
.lang-menu small { color: var(--muted); font-weight: 700; }

h1 { font-size: 27px; margin: 10px 0 6px; letter-spacing: -.02em; }
h2 { font-size: 20px; margin: 22px 0 10px; letter-spacing: -.01em; }
p.lead { color: var(--muted); margin: 0 0 18px; font-size: 17px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); transition: background-color .25s, border-color .25s; }
#app > * { animation: rise .28s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

/* hero */
.hero { background: var(--hero); color: #fff; border-radius: 20px; padding: 30px 26px; position: relative; overflow: hidden; box-shadow: var(--shadow-lg); }
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 240px; height: 240px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero::before { content: ""; position: absolute; right: 60px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.06); }
.hero h1 { color: #fff; font-size: 32px; margin: 0 0 8px; max-width: 620px; position: relative; z-index: 1; }
.hero p { margin: 0 0 18px; max-width: 600px; opacity: .93; font-size: 17px; position: relative; z-index: 1; }
.hero .btn { background: #fff; color: #0b6e4f; border-color: #fff; position: relative; z-index: 1; }
.hero-stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; position: relative; z-index: 1; }
.hero-stats div { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); border-radius: 12px; padding: 8px 14px; font-size: 14px; }
.hero-stats b { font-size: 20px; margin-right: 5px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.section-card { display: flex; flex-direction: column; transition: transform .18s, box-shadow .18s, border-color .18s; position: relative; overflow: hidden; }
.section-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--brand); }
.section-card .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 10px; }
.section-card h3 { margin: 0 0 6px; font-size: 18px; }
.section-card p { margin: 0 0 12px; color: var(--muted); font-size: 14px; flex: 1; }
.section-card .meta { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.section-card.mixed { border-style: dashed; }
.bar { height: 5px; background: var(--bg2); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 3px; transition: width .8s cubic-bezier(.2,.8,.2,1); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--brand); background: var(--brand); color: var(--brand-ink); padding: 10px 16px; border-radius: 11px; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; transition: transform .12s, filter .15s, box-shadow .15s; font-family: inherit; }
.btn:hover { filter: brightness(1.07); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.secondary { background: var(--card); color: var(--brand); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.small { padding: 6px 12px; min-height: 36px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.up { text-transform: uppercase; letter-spacing: .04em; }
.resume { margin-top: 14px; background: var(--warn-soft); border-color: var(--warn-line); }

/* mode picker */
.modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.mode { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; background: var(--card); transition: border-color .15s, background .15s, transform .15s; }
.mode:hover { transform: translateY(-2px); }
.mode:hover, .mode.active { border-color: var(--brand); background: var(--brand-soft); }
.mode h4 { margin: 0 0 4px; }
.mode p { margin: 0; font-size: 14px; color: var(--muted); }
.count-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.count-row button { min-width: 56px; }

/* quiz */
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 18px; padding: 6px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.timer.low { color: var(--bad); border-color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.progress { height: 7px; background: var(--bg2); border-radius: 4px; overflow: hidden; margin-bottom: 14px; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-2)); transition: width .35s; border-radius: 4px; }
.qtext { font-size: 19px; font-weight: 700; margin: 4px 0 14px; }
.qimg { max-width: 100%; border-radius: 8px; margin-bottom: 12px; }
.answers { display: flex; flex-direction: column; gap: 10px; }
.answer { display: flex; gap: 12px; align-items: flex-start; border: 2px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; background: var(--card); min-height: 48px; text-align: left; font-size: 16px; width: 100%; color: var(--ink); font-family: inherit; transition: border-color .12s, background .12s, transform .12s; }
.answer:not(:disabled):hover { border-color: var(--brand); transform: translateX(3px); }
.answer:not(:disabled):active { transform: scale(.99); }
.answer.selected { border-color: var(--brand); background: var(--brand-soft); }
.answer.correct { border-color: var(--good); background: var(--good-soft); animation: pop .2s; }
.answer.wrong { border-color: var(--bad); background: var(--bad-soft); animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.answer .key { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; background: var(--key); }
.answer.selected .key { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.answer:disabled { cursor: default; }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); border: 1px solid var(--warn-line); font-size: 15px; animation: rise .25s; }
.explain.good { background: var(--good-soft); border-color: var(--good-line); }
.explain.bad { background: var(--bad-soft); border-color: var(--bad-line); }
.navgrid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.navgrid button { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; font-weight: 700; font-size: 13px; transition: transform .1s; }
.navgrid button:hover { transform: scale(1.1); }
.navgrid button.answered { background: var(--brand-soft); border-color: var(--brand); }
.navgrid button.flagged { background: var(--warn-soft); border-color: var(--warn); }
.navgrid button.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.navgrid button.ok { background: var(--good-soft); border-color: var(--good); }
.navgrid button.no { background: var(--bad-soft); border-color: var(--bad); }

/* result */
.score { display: flex; gap: 22px; flex-wrap: wrap; align-items: center; }
.ring { position: relative; width: 132px; height: 132px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring .track { stroke: var(--bg2); }
.ring .val { stroke: var(--good); stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.2,.8,.2,1); }
.ring.bad .val { stroke: var(--bad); }
.ring .big { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 31px; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 16px; }
.stat { background: var(--bg2); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-size: 20px; }
.review .item { border-top: 1px solid var(--line); padding: 14px 0; }
.review .item:first-child { border-top: 0; padding-top: 0; }
.review .item h4 { margin: 0 0 8px; font-size: 16px; }
.review .ans { padding: 4px 0; font-size: 15px; }
.review .ans.correct { color: var(--good); font-weight: 700; }
.review .ans.wrong { color: var(--bad); text-decoration: line-through; }
.src { font-size: 13px; color: var(--muted); }
.signup-hint { margin-top: 16px; padding: 12px 14px; background: var(--brand-soft); border-radius: 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; }
.signup-hint button { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; max-width: 460px; width: 100%; animation: pop .16s; }
textarea, input[type=text], input[type=number], select { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: var(--card); color: var(--ink); }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
footer { margin: 40px auto 24px; text-align: center; color: var(--muted); font-size: 13px; max-width: 640px; padding: 0 16px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 70; animation: rise .2s; }

/* tables / admin */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg2); font-weight: 700; }
code { background: var(--bg2); padding: 1px 5px; border-radius: 5px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.tabs button { border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 700; }
.tabs button.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.err { color: var(--bad); font-size: 14px; }
.ok { color: var(--good); font-size: 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.toolbar input[type=text], .toolbar select { width: auto; min-width: 160px; }

@media (max-width: 640px) {
  h1 { font-size: 22px; }
  .hero { padding: 22px 18px; border-radius: 16px; } .hero h1 { font-size: 25px; } .hero p { font-size: 16px; }
  .qtext { font-size: 17px; }
  header.top .container { gap: 6px; }
  nav { order: 3; width: 100%; } nav a { flex: 1; text-align: center; padding: 6px 2px; font-size: 13px; white-space: nowrap; }
  .ring { width: 110px; height: 110px; } .ring .big { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* profil */
.profile-head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.avatar { width: 76px; height: 76px; border-radius: 50%; background: var(--hero); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; flex: none; box-shadow: var(--shadow); }
.profile-head h1 { margin: 0; }
.level { margin-top: 14px; }
.level .bar { height: 9px; margin: 6px 0 4px; }
.sec-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); align-items: center; }
.sec-row:first-of-type { border-top: 0; }
.sec-row .bar { grid-column: 1 / -1; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .avatar { width: 62px; height: 62px; font-size: 23px; } }

mark { background: var(--warn-soft); color: inherit; border-radius: 3px; padding: 0 2px; }

/* Telefon: +998 qotirilgan prefiks */
.phone-field { display: flex; align-items: stretch; width: 100%; border: 1px solid var(--line); border-radius: 9px; background: var(--card); overflow: hidden; }
.phone-field:focus-within { outline: 2px solid var(--brand, #2563eb); outline-offset: 1px; }
.phone-field .pf-pre { display: flex; align-items: center; padding: 0 10px; background: var(--bg2, rgba(127,127,127,.12)); color: var(--muted, #6b7280); font-weight: 600; border-right: 1px solid var(--line); user-select: none; }
.phone-field input { flex: 1; min-width: 0; padding: 10px; border: 0; background: transparent; color: var(--ink); font: inherit; letter-spacing: .5px; }
.phone-field input:focus { outline: none; }

/* Yangi versiya taklifi */
.upd-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 75; display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); background: var(--ink); color: var(--bg); padding: 8px 8px 8px 16px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 14px; animation: rise .2s; }
.upd-bar .btn { white-space: nowrap; flex: none; }

/* Telefonga oʻrnatish taklifi va internetsiz rejim chizigʻi */
.install-bar { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; display: flex; gap: 12px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 14px; z-index: 55; animation: pop .2s; }
.install-bar .ib-ico { width: 44px; height: 44px; border-radius: 10px; flex: none; }
.install-bar .btn-row { margin-top: 10px; }
.netbar { background: var(--warn-soft); border-bottom: 1px solid var(--warn-line); color: var(--ink); text-align: center; font-size: 14px; padding: 7px 12px; }
/* bo'limlar guruhi (masalan, normativ hujjatlar) */
.group-card { border-color: var(--brand); background: linear-gradient(180deg, var(--brand-soft), var(--card) 55%); }
.group-card .sub-list { list-style: none; margin: 4px 0 10px; padding: 0; display: grid; gap: 4px; }
.group-card .sub-list a { color: inherit; text-decoration: none; font-size: .92rem; }
.group-card .sub-list a:hover { text-decoration: underline; }

/* natija kartochkasi (ulashish oynasi) */
.share-modal { max-width: 480px; max-height: calc(100vh - 32px); overflow-y: auto; }
.share-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.share-head h3 { margin: 0; }
.share-img { position: relative; border-radius: 14px; overflow: hidden; background: #0b6e4f; aspect-ratio: 1 / 1; }
.share-img img { display: block; width: 100%; height: 100%; object-fit: cover; transition: opacity .2s; }
.share-wait { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; text-align: center; padding: 20px; }
.share-wait[hidden] { display: none; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--ink); margin: 12px 0 2px; cursor: pointer; }
label.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.share-grid .btn { width: 100%; font-size: 14px; padding: 10px 8px; line-height: 1.25; }
.share-grid #shDl { grid-column: 1 / -1; }
.share-grid .share-native { grid-column: 1 / -1; }
.share-grid .share-native[hidden] { display: none; }
.btn.sh-tg { background: #229ed9; border-color: #229ed9; color: #fff; }
.btn.sh-wa { background: #1fae54; border-color: #1fae54; color: #fff; }
.btn.sh-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.share-cta { display: flex; gap: 14px; align-items: flex-start; background: var(--brand-soft); border-color: var(--brand); }
.share-cta .sc-ico { font-size: 34px; line-height: 1; }
.share-cta .btn-row { margin-top: 10px; }
.icon-btn.sm { height: 30px; min-width: 30px; padding: 0 6px; font-size: 14px; vertical-align: middle; }
td.nowrap { white-space: nowrap; }
