:root {
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --ink: #111827;
  --ink-2: #374151;
  --muted: #6b7280;
  --line: #e6e8f0;
  --accent: #4f46e5;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --ok: #059669;
  --ok-soft: #e7f8f1;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fff5e5;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(17, 24, 39, .04), 0 8px 28px -12px rgba(17, 24, 39, .12);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num { font-variant-numeric: tabular-nums; }

/* ── Umumiy elementlar ── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 12px; border: 1px solid transparent;
  font-weight: 600; font-size: 15px; transition: transform .08s, background .15s, opacity .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px var(--accent); }
.btn-primary:hover:not(:disabled) { background: #4338ca; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-lg { height: 54px; font-size: 16px; padding: 0 26px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn-block { width: 100%; }

.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input {
  height: 50px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s, background .15s;
  width: 100%;
}
.input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 4px var(--accent-soft); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 12px;
  border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--line); white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.live .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

.logo {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; font-weight: 800; font-size: 15px; letter-spacing: .5px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 13px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── O'quvchi sahifasi ── */
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 420px; padding: 32px; }
.login h2 { font-size: 26px; letter-spacing: -.02em; margin: 28px 0 6px; }
.login .sub { color: var(--muted); margin: 0 0 24px; }
.login form { display: grid; gap: 16px; }
.hint { font-size: 13px; color: var(--muted); margin: 18px 0 0; display: flex; gap: 8px; align-items: flex-start; }
.error-text { color: var(--bad); font-size: 14px; min-height: 20px; margin: -4px 0 0; }

.lobby { width: 100%; max-width: 520px; padding: 40px 32px; text-align: center; }
.avatar {
  width: 76px; height: 76px; border-radius: 24px; margin: 0 auto 18px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 26px;
}
.lobby h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.02em; }
.lobby .sub { color: var(--muted); margin: 0; }
.waiting {
  margin: 28px auto; display: inline-flex; align-items: center; gap: 12px; padding: 14px 20px;
  border-radius: 14px; background: var(--surface-2); border: 1px dashed var(--line); font-weight: 600; color: var(--ink-2);
}
.loader { display: inline-flex; gap: 5px; }
.loader i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite ease-in-out; }
.loader i:nth-child(2) { animation-delay: .15s; }
.loader i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.fact { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 14px 8px; }
.fact b { display: block; font-size: 22px; letter-spacing: -.02em; }
.fact span { font-size: 12px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; margin-top: 22px; padding: 4px; }

.exam { max-width: 760px; margin: 0 auto; padding: 20px 16px 48px; }
.exam-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .avatar { width: 40px; height: 40px; border-radius: 12px; font-size: 15px; margin: 0; }
.who b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--muted); }
.timer {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-variant-numeric: tabular-nums; font-size: 16px;
}
.timer.low { color: var(--bad); border-color: #f6c4c4; background: var(--bad-soft); }

.progress-wrap { margin-bottom: 18px; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 8px; font-weight: 500; }
.progress-meta b { color: var(--ink); }
.bar { height: 8px; background: #e7e9f3; border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #4f46e5, #7c3aed); border-radius: inherit; transition: width .4s ease; }

.qcard { padding: 28px; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 16px; }
.qnum { font-size: 13px; color: var(--muted); font-weight: 600; }
.qtext { font-size: 21px; line-height: 1.45; font-weight: 650; letter-spacing: -.01em; margin: 0 0 24px; }
.options { display: grid; gap: 10px; }
.opt {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 14px 16px; min-height: 60px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); font-size: 16px; font-weight: 500;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.opt:hover { border-color: #c7c9f5; background: #fafaff; }
.opt .key {
  width: 34px; height: 34px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-weight: 700; font-size: 14px; color: var(--muted);
  transition: .12s;
}
.opt.sel { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.opt.sel .key { background: var(--accent); border-color: var(--accent); color: #fff; }
.qfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 24px; }
.kbd-hint { font-size: 12px; color: var(--muted); }
kbd {
  font-family: inherit; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--line); border-bottom-width: 2px;
}

.result { width: 100%; max-width: 560px; padding: 36px 32px; text-align: center; }
.ring { position: relative; width: 168px; height: 168px; margin: 0 auto 22px; }
.ring svg { transform: rotate(-90deg); }
.ring .val { position: absolute; inset: 0; display: grid; place-content: center; }
.ring .val b { font-size: 40px; letter-spacing: -.03em; line-height: 1; }
.ring .val span { font-size: 13px; color: var(--muted); margin-top: 4px; }
.result h2 { font-size: 26px; letter-spacing: -.02em; margin: 0 0 6px; }
.result .sub { color: var(--muted); margin: 0 0 24px; }
.result .facts .fact b.ok { color: var(--ok); }
.result .facts .fact b.bad { color: var(--bad); }

.review { max-width: 760px; margin: 0 auto; padding: 0 16px 48px; }
.review h3 { font-size: 18px; margin: 8px 0 14px; }
.rv { padding: 16px 18px; margin-bottom: 10px; border-left: 4px solid var(--ok); }
.rv.no { border-left-color: var(--bad); }
.rv .t { font-weight: 600; margin: 0 0 8px; }
.rv .a { font-size: 14px; color: var(--ink-2); display: grid; gap: 3px; }
.rv .a .ok { color: var(--ok); font-weight: 600; }
.rv .a .bad { color: var(--bad); font-weight: 600; text-decoration: line-through; }

@media (max-width: 560px) {
  .qcard { padding: 20px; }
  .qtext { font-size: 18px; }
  .kbd-hint { display: none; }
  .qfoot .btn { width: 100%; }
  .login, .lobby, .result { padding: 28px 20px; }
}

/* ── Admin paneli ── */
.topbar {
  position: sticky; top: 0; z-index: 10; background: rgba(244, 245, 250, .85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1360px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar .spacer { flex: 1; }
.join-url { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.join-url code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); padding: 6px 10px; border-radius: 9px; cursor: pointer;
}
.admin { max-width: 1360px; margin: 0 auto; padding: 20px; display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.panel { padding: 22px; }
.panel h2 { font-size: 16px; margin: 0 0 18px; letter-spacing: -.01em; }
.controls { display: grid; gap: 16px; position: sticky; top: 86px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field small { font-size: 12px; color: var(--muted); }
.stepper { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); height: 50px; overflow: hidden; }
.stepper:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.stepper button { width: 38px; height: 100%; border: 0; background: none; font-size: 18px; color: var(--muted); flex: none; }
.stepper button:hover:not(:disabled) { color: var(--accent); background: var(--accent-soft); }
.stepper input { flex: 1; min-width: 0; border: 0; background: none; text-align: center; font-size: 18px; font-weight: 700; outline: none; height: 100%; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.topics { display: grid; gap: 6px; }
.topic {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 14px; font-weight: 500; user-select: none; transition: .12s;
}
.topic input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.topic span { flex: 1; }
.topic em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 600; }
.topic:has(input:checked) { border-color: #c7c9f5; background: #fafaff; }
.topic.disabled { opacity: .6; cursor: default; }
.actions { display: grid; gap: 10px; }
.actions .sub-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.live-box { border-radius: 14px; padding: 16px; background: var(--accent-soft); display: grid; gap: 4px; text-align: center; }
.live-box .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--accent); }
.live-box span { font-size: 13px; color: var(--ink-2); }

.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { padding: 16px 18px; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat b { display: block; font-size: 28px; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat.ok b { color: var(--ok); }
.stat.accent b { color: var(--accent); }

.table-card { overflow: hidden; }
.table-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.table-head h2 { margin: 0; font-size: 16px; flex: 1; }
.table-head .input { height: 38px; font-size: 14px; width: 220px; border-radius: 10px; }
.table-head select { height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); padding: 0 10px; font-size: 14px; }
.tbl-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbff; }
.td-name { display: flex; align-items: center; gap: 10px; }
.td-name .av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--accent-soft); color: var(--accent); position: relative; flex: none; }
.td-name .av::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--surface); background: #cbd5e1; }
.td-name .av.on::after { background: #10b981; }
.td-name b { font-weight: 600; }
.mini-bar { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.mini-bar .bar { flex: 1; height: 6px; }
.mini-bar span { font-size: 13px; color: var(--ink-2); font-weight: 600; min-width: 48px; text-align: right; }
.c-ok { color: var(--ok); font-weight: 700; }
.c-bad { color: var(--bad); font-weight: 700; }
.c-muted { color: var(--muted); }
.blur-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; color: var(--warn); background: var(--warn-soft); padding: 2px 8px; border-radius: 999px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: var(--surface-2); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); border-color: transparent; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: grid; place-items: center; padding: 16px; z-index: 40; animation: fadeIn .2s; }
.modal { width: 100%; max-width: 680px; max-height: 86vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { overflow: auto; padding: 16px 20px 20px; }
.rv.pending { border-left-color: #cbd5e1; opacity: .7; }

.login-admin { max-width: 380px; }

@media (max-width: 1100px) {
  .admin { grid-template-columns: 1fr; }
  .controls { position: static; }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .table-head .input { width: 100%; }
  .join-url { width: 100%; }
}
