:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --text: #16192b;
  --muted: #646b85;
  --line: #e3e6f0;
  --brand: #3b4cf0;
  --brand-dark: #2a37c4;
  --brand-soft: #eceefe;
  --good: #14a46c;
  --good-soft: #e3f6ee;
  --mid: #d99206;
  --mid-soft: #fdf3dc;
  --low: #e0453a;
  --low-soft: #fde8e6;
  --none: #b4b9cc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(22, 25, 43, .05), 0 4px 16px rgba(22, 25, 43, .05);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; }
.nowrap { white-space: nowrap; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 460px; }

/* Header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); letter-spacing: .04em; }
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), #7a5cf5); color: #fff; font-weight: 800;
}
.logo small { display: block; font-weight: 500; font-size: .72rem; color: var(--muted); letter-spacing: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.nav a, .nav button.linklike {
  padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: .95rem;
}
.nav a:hover, .nav a.active { background: var(--brand-soft); color: var(--brand); text-decoration: none; }

main { padding: 24px 0 48px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.grid > .card, .grid > a.card { margin-top: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stack > * + * { margin-top: 16px; }

.stat { padding: 16px 18px; }
.stat .value { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: .9rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 11px; padding: 10px 18px;
  font: inherit; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff;
  text-decoration: none; transition: background .15s;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn-light { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-light:hover { background: var(--surface-2); }
.btn-danger { background: var(--surface); color: var(--low); border-color: #f3c3be; }
.btn-danger:hover { background: var(--low-soft); }
.btn-tg { background: #229ed9; }
.btn-tg:hover { background: #1a87bb; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: .875rem; border-radius: 9px; }
.linklike { background: none; border: 0; font: inherit; cursor: pointer; color: var(--brand); padding: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; }

/* Forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.field .help { color: var(--muted); font-size: .85rem; margin-top: 4px; }
input[type=text], input[type=number], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
.checkbox-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px 18px; }
.checkbox-list label { font-weight: 500; display: flex; align-items: center; gap: 8px; margin: 0; }
.code-input { font-size: 1.7rem !important; letter-spacing: .45em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--low); font-size: .9rem; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters > * { width: auto; flex: 1 1 160px; }
.filters .btn { flex: 0 0 auto; }

/* Messages */
.messages { list-style: none; padding: 0; margin: 0 0 16px; }
.messages li { padding: 12px 16px; border-radius: 12px; margin-bottom: 8px; background: var(--brand-soft); color: var(--brand-dark); }
.messages li.success { background: var(--good-soft); color: #0b7a4f; }
.messages li.error { background: var(--low-soft); color: #b42b21; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
tr:last-child td { border-bottom: 0; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-good { background: var(--good-soft); color: #0b7a4f; border-color: transparent; }
.badge-mid { background: var(--mid-soft); color: #9a6604; border-color: transparent; }
.badge-low { background: var(--low-soft); color: #b42b21; border-color: transparent; }
.badge-brand { background: var(--brand-soft); color: var(--brand-dark); border-color: transparent; }

.code-box {
  display: inline-block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1.9rem; font-weight: 800;
  letter-spacing: .25em; background: var(--brand-soft); color: var(--brand-dark); padding: 8px 16px 8px 22px; border-radius: 12px;
}

/* Progress bars */
.bar { height: 10px; background: #edf0f6; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--none); }
.lv-good .bar > span, .bar.lv-good > span { background: var(--good); }
.lv-mid .bar > span, .bar.lv-mid > span { background: var(--mid); }
.lv-low .bar > span, .bar.lv-low > span { background: var(--low); }
.score { font-weight: 800; font-variant-numeric: tabular-nums; }
.lv-good .score, .score.lv-good { color: var(--good); }
.lv-mid .score, .score.lv-mid { color: var(--mid); }
.lv-low .score, .score.lv-low { color: var(--low); }
.lv-none .score, .score.lv-none { color: var(--none); }

.topic-row { display: grid; grid-template-columns: 1fr 120px 52px; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.topic-row:last-child { border-bottom: 0; }
.topic-row .name { min-width: 0; }
.topic-row .name small { display: block; color: var(--muted); font-size: .8rem; }
.topic-row .score { text-align: right; }
.topic-row .name small.topic-desc { color: #8a90a8; font-size: .78rem; line-height: 1.35; margin: 2px 0; }

/* Ring (average) */
.ring {
  --p: 0; --c: var(--none);
  width: 92px; height: 92px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), #edf0f6 0);
  display: grid; place-items: center;
}
.ring::before { content: ""; grid-area: 1 / 1; width: 72px; height: 72px; border-radius: 50%; background: var(--surface); }
.ring b { grid-area: 1 / 1; z-index: 1; font-size: 1.3rem; }
.ring.lv-good { --c: var(--good); } .ring.lv-mid { --c: var(--mid); } .ring.lv-low { --c: var(--low); }

.child-card { display: flex; gap: 18px; align-items: center; color: inherit; }
.child-card:hover { text-decoration: none; }
.child-card .info { flex: 1; min-width: 0; }
.kpis { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: .9rem; margin-top: 6px; }
.kpis b { color: var(--text); }

.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; text-align: center; }
.compare .big { font-size: 2rem; font-weight: 800; }
.compare .arrow { font-size: 1.6rem; color: var(--muted); }

/* Landing */
.hero { padding: 28px 0 8px; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 5vw, 2.6rem); max-width: 720px; margin: 0 auto .5em; }
.hero p { color: var(--muted); max-width: 600px; margin: 0 auto 1.4em; font-size: 1.08rem; }
.hero .actions { justify-content: center; }
.features { margin-top: 36px; }
.feature .icon { font-size: 1.6rem; margin-bottom: 6px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 42px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); font-weight: 700; font-size: .9rem;
}

.auth-card { margin-top: 12px; }
.auth-card h1 { font-size: 1.45rem; }
.divider { text-align: center; color: var(--muted); font-size: .9rem; margin: 18px 0; }

footer { color: var(--muted); font-size: .85rem; text-align: center; padding: 0 0 32px; }

/* Panel layout */
.panel-nav { background: var(--text); }
.panel-nav .logo, .panel-nav .logo small { color: #fff; }
.panel-nav .logo small { opacity: .6; }
.panel-nav .nav a { color: #c5c9db; }
.panel-nav .nav a:hover, .panel-nav .nav a.active { background: rgba(255,255,255,.1); color: #fff; }
.panel-nav .nav button.linklike { color: #c5c9db; padding: 8px 12px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; }
.breadcrumb { font-size: .9rem; color: var(--muted); margin-bottom: 6px; }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .topic-row { grid-template-columns: 1fr 70px 44px; gap: 8px; }
  .child-card { gap: 14px; }
  .ring { width: 74px; height: 74px; }
  .ring::before { width: 58px; height: 58px; }
  .ring b { font-size: 1.1rem; }
  .topbar .container { flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .nav { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .nav a { white-space: nowrap; }
}

/* Print: guruh kodlari varaqasi */
.code-sheet { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.code-slip { border: 1.5px dashed #9aa0b8; border-radius: 12px; padding: 14px 16px; break-inside: avoid; background: #fff; }
.code-slip .code-box { font-size: 1.5rem; margin: 6px 0; }
@media print {
  .no-print, .topbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .card { border: 0; box-shadow: none; padding: 0; }
}

/* ---------- Test ---------- */
.test-who { display: flex; flex-direction: column; align-items: flex-end; text-align: right; line-height: 1.3; }
.student-pick { display: grid; gap: 8px; }
.pick-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  font: inherit; font-weight: 600; text-align: left; padding: 14px 16px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.pick-btn:hover { border-color: var(--brand); background: var(--brand-soft); }

.test-nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.nav-dot {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-weight: 600; cursor: pointer; color: var(--muted);
}
.nav-dot.answered { background: var(--good-soft); border-color: transparent; color: #0b7a4f; }
.nav-dot.current { outline: 2px solid var(--brand); outline-offset: 1px; color: var(--text); }
.test-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.btn:disabled { opacity: .4; cursor: default; }

.question-card .question-text { font-size: 1.2rem; margin: 6px 0 14px; }
.code-view {
  background: #1b1f33; color: #e6e9f5; padding: 14px 16px; border-radius: 12px; overflow-x: auto;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; margin: 0 0 16px; white-space: pre;
}
.choices { display: grid; gap: 10px; }
.choices-preview { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; font: inherit; cursor: pointer;
  padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; color: var(--text);
}
.choices-preview .choice { flex-direction: column; align-items: stretch; }
.choice:hover { border-color: #b9c0f7; }
.choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.choice-letter {
  flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: .9rem;
}
.choice.selected .choice-letter { background: var(--brand); color: #fff; border-color: var(--brand); }
.choice-text { font-size: 1rem; white-space: pre-wrap; }
.mini-preview { width: 100%; height: 130px; border: 1px solid var(--line); border-radius: 8px; background: #fff; pointer-events: none; }
.answer-input { font-family: ui-monospace, Menlo, Consolas, monospace !important; font-size: 1.15rem !important; max-width: 360px; }

.code-lines { background: #1b1f33; border-radius: 12px; padding: 8px 0; overflow-x: auto; }
.code-line {
  display: flex; gap: 14px; width: 100%; text-align: left; background: none; border: 0; cursor: pointer;
  padding: 3px 16px; color: #e6e9f5; font: 14px/1.6 ui-monospace, Menlo, Consolas, monospace; white-space: pre;
}
.code-line code { font: inherit; }
.code-line .ln { color: #6f7696; min-width: 22px; text-align: right; }
.code-line:hover { background: rgba(255,255,255,.06); }
.code-line.selected { background: rgba(224, 69, 58, .35); }

.requirements { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 6px; }
.requirements li { padding-left: 28px; position: relative; }
.requirements li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); box-sizing: border-box;
}
.requirements li.ok { color: #0b7a4f; }
.requirements li.ok::before { content: "✓"; background: var(--good); border-color: var(--good); color: #fff; font-size: 12px; display: grid; place-items: center; }
.editor-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.editor-label { font-size: .8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.code-editor {
  width: 100%; min-height: 360px; resize: vertical; background: #1b1f33 !important; color: #e6e9f5 !important;
  font: 14px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; padding: 12px 14px !important; tab-size: 2;
}
.code-preview { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.result-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.result-row:last-child { border-bottom: 0; }
.grow { flex: 1; }
.pin-big { font: 800 clamp(3rem, 10vw, 5.5rem)/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .15em; color: var(--brand-dark); }
@media (max-width: 760px) {
  .editor-wrap { grid-template-columns: 1fr; }
  .code-editor, .code-preview { min-height: 240px; height: 240px; }
}
.mono-input { font-family: ui-monospace, Menlo, Consolas, monospace !important; font-size: .9rem !important; }
