:root {
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #1c2433;
  --muted: #667085;
  --line: #e3e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e8efff;
  --ok: #16a34a;
  --ok-soft: #e7f7ed;
  --warn: #d97706;
  --warn-soft: #fff4e0;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 17px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
.narrow { max-width: 760px; }

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px;
}
.brand .name { font-weight: 700; font-size: 19px; }
.brand .sub { color: var(--muted); font-size: 14px; }

h1 { font-size: 28px; margin: 8px 0 4px; }
.lead { color: var(--muted); margin: 0 0 24px; }

.steps { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.steps span {
  font-size: 14px; padding: 4px 12px; border-radius: 999px; background: var(--line); color: var(--muted);
}
.steps span.on { background: var(--primary); color: #fff; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.tile {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 92px; padding: 16px; background: var(--card); border: 2px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text);
  font-size: 24px; font-weight: 700; transition: .15s;
}
.tile:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }
.tile.name { font-size: 18px; font-weight: 600; justify-content: flex-start; text-align: left; min-height: 64px; }

.search {
  width: 100%; padding: 14px 16px; font-size: 18px; border: 2px solid var(--line);
  border-radius: var(--radius); margin-bottom: 16px; outline: none; background: var(--card);
}
.search:focus { border-color: var(--primary); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.test-card { display: flex; flex-direction: column; gap: 10px; }
.test-card h3 { margin: 0; font-size: 20px; }
.meta { color: var(--muted); font-size: 15px; }
.badge {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.new { background: var(--primary-soft); color: var(--primary); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; font-size: 17px; font-weight: 600; border-radius: 12px; border: 0;
  background: var(--primary); color: #fff; cursor: pointer; transition: .15s; font-family: inherit;
}
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary-soft); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--bad); }
.btn.success { background: var(--ok); }
.btn:disabled { background: var(--line); color: var(--muted); cursor: not-allowed; }
.btn.block { width: 100%; }

.back { display: inline-block; margin-bottom: 12px; font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------------- Test ishlash sahifasi ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(16, 24, 40, .05);
}
.topbar .in {
  max-width: 1200px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.topbar .who { flex: 1; min-width: 200px; }
.topbar .who b { display: block; font-size: 17px; }
.topbar .who span { color: var(--muted); font-size: 14px; }
.timer {
  font-variant-numeric: tabular-nums; font-size: 30px; font-weight: 800; letter-spacing: 1px;
  padding: 4px 16px; border-radius: 12px; background: var(--primary-soft); color: var(--primary);
}
.timer.low { background: var(--bad-soft); color: var(--bad); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .6; } }
.progress { font-size: 15px; color: var(--muted); }
.progress b { color: var(--text); }

.net {
  font-size: 14px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok);
}
.net.saving { background: var(--warn-soft); color: var(--warn); }
.net.off { background: var(--bad-soft); color: var(--bad); }

.layout {
  max-width: 1200px; margin: 0 auto; padding: 20px 16px 80px;
  display: grid; grid-template-columns: 260px 1fr; gap: 20px; align-items: start;
}
.sidebar { position: sticky; top: 90px; max-height: calc(100vh - 110px); overflow: auto; }
.sidebar h4 { margin: 12px 0 8px; font-size: 15px; color: var(--muted); }
.sidebar h4:first-child { margin-top: 0; }
.nums { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nums a {
  display: grid; place-items: center; height: 38px; border-radius: 8px; font-weight: 600; font-size: 15px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
}
.nums a.done { background: var(--ok); color: #fff; border-color: var(--ok); }
.nums a.pending { background: var(--warn); color: #fff; border-color: var(--warn); }

.subject-title {
  font-size: 22px; margin: 28px 0 12px; padding: 10px 16px; border-radius: 12px;
  background: var(--primary); color: #fff;
}
.subject-title:first-child { margin-top: 0; }

.question { margin-bottom: 14px; scroll-margin-top: 100px; }
.question .q-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.question .q-num {
  flex: none; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700;
}
.question.answered .q-num { background: var(--ok); color: #fff; }
.question .q-text { white-space: pre-wrap; font-size: 18px; font-weight: 500; padding-top: 4px; }
.question img { max-width: 100%; max-height: 360px; border-radius: 10px; margin: 0 0 12px 48px; display: block; }

.options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-left: 48px; }
.option {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; cursor: pointer; background: var(--card); transition: .12s; user-select: none;
}
.option:hover { border-color: #b8c8f5; background: #fafcff; }
.option input { display: none; }
.option .letter {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: var(--bg); border: 2px solid var(--line);
}
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.selected .letter { background: var(--primary); border-color: var(--primary); color: #fff; }
.option.pending { border-color: var(--warn); background: var(--warn-soft); }
.option.pending .letter { background: var(--warn); border-color: var(--warn); color: #fff; }

.nums a.current { outline: 3px solid var(--primary); outline-offset: 1px; }

.question { padding: 24px; margin-bottom: 0; }
.q-subject {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--muted);
}
.q-subject span:first-child { font-weight: 700; color: var(--primary); }
.question .q-text { font-size: 20px; }
.question .option { padding: 14px 16px; font-size: 18px; }

.q-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; }
.q-nav .q-pos { color: var(--muted); font-weight: 600; }
.q-nav .btn { min-width: 150px; }

.modal-bg {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: none;
  align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal-bg.show { display: flex; }
.modal { background: var(--card); border-radius: 18px; padding: 28px; max-width: 440px; width: 100%; text-align: center; }
.modal h2 { margin: 0 0 8px; }
.modal p { color: var(--muted); }
.modal .actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }

.offline-banner {
  display: none; background: var(--bad); color: #fff; text-align: center; padding: 8px 16px; font-weight: 600;
}
.offline-banner.show { display: block; }

/* ---------------- Natija ---------------- */
.result-hero { text-align: center; padding: 32px 20px; }
.score-ring {
  width: 170px; height: 170px; border-radius: 50%; margin: 10px auto 16px; display: grid; place-items: center;
  background: conic-gradient(var(--ok) calc(var(--p) * 1%), var(--line) 0);
}
.score-ring .inner {
  width: 136px; height: 136px; border-radius: 50%; background: var(--card); display: grid; place-items: center;
}
.score-ring b { font-size: 36px; display: block; line-height: 1; }
.score-ring span { color: var(--muted); font-size: 15px; }
table.results { width: 100%; border-collapse: collapse; margin-top: 8px; }
table.results th, table.results td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: center; }
table.results th:first-child, table.results td:first-child { text-align: left; }
table.results th { color: var(--muted); font-size: 14px; font-weight: 600; }
.c-ok { color: var(--ok); font-weight: 700; }
.c-bad { color: var(--bad); font-weight: 700; }
.c-muted { color: var(--muted); }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: none; }
  .nums { grid-template-columns: repeat(10, 1fr); }
  .options { grid-template-columns: 1fr; padding-left: 0; }
  .question img { margin-left: 0; }
  .timer { font-size: 24px; }
}
