/* Nazorat — o'qituvchi paneli */
:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e2e5ea;
    --text: #1d2330;
    --muted: #6b7384;
    --accent: #2f5bea;
    --accent-ink: #ffffff;
    --accent-soft: #e8eefe;
    --good: #16794c;
    --good-soft: #e3f4ea;
    --mid: #9a6200;
    --mid-soft: #fdf1dc;
    --bad: #c23934;
    --bad-soft: #fbe7e6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151b;
        --surface: #1a1e26;
        --surface-2: #222833;
        --border: #2e3542;
        --text: #e6e9ef;
        --muted: #9aa3b2;
        --accent: #6d8cff;
        --accent-ink: #0d1020;
        --accent-soft: #232c4a;
        --good: #4cc38a;
        --good-soft: #17301f;
        --mid: #e3a63b;
        --mid-soft: #33270f;
        --bad: #ff7b72;
        --bad-soft: #3a1c1b;
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

code, pre { font-family: var(--mono); font-size: 13px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; overflow-x: auto; margin: 6px 0; white-space: pre; }
code { background: var(--surface-2); border-radius: 4px; padding: 1px 4px; }
pre code { background: none; padding: 0; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.side {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 18px 12px;
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 4px;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 4px 10px 18px; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

.nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav .ico { width: 20px; text-align: center; }
.side .spacer { flex: 1; }
.side form button { width: 100%; }

main { padding: 26px 32px 60px; max-width: 1240px; width: 100%; min-width: 0; }
.app > *, .grid > *, .stack > * { min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards / grid ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 16px; }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.side-r { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack > * + * { margin-top: 16px; }

.kpi .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .lbl { color: var(--muted); font-size: 13px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }
tr.dim td { opacity: .55; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.mid { background: var(--mid-soft); color: var(--mid); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.pct { font-weight: 600; font-variant-numeric: tabular-nums; }
.pct.good { color: var(--good); }
.pct.mid { color: var(--mid); }
.pct.bad { color: var(--bad); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Bars ---------- */
.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bar.good > span { background: var(--good); }
.bar.mid > span { background: var(--mid); }
.bar.bad > span { background: var(--bad); }

.spark { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.spark .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.spark .col span { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.spark .col small { font-size: 11px; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 90px; resize: vertical; font-family: var(--mono); font-size: 14px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.row { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; min-width: 160px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { min-width: 240px; flex: 1; }
.filters select { width: auto; }

.option { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: start; margin-bottom: 8px; }
.option .letter { display: flex; align-items: center; justify-content: center; gap: 4px; height: 40px; border: 1px solid var(--border); border-radius: 8px; font-weight: 700; cursor: pointer; }
.option .letter:has(input:checked) { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.option .letter input { position: absolute; opacity: 0; pointer-events: none; }
.option textarea { min-height: 40px; height: 40px; }

.topic-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.topic-pick label { font-weight: 500; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; display: flex; gap: 8px; align-items: center; margin: 0; cursor: pointer; }
.topic-pick label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.topic-pick small { margin-left: auto; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn, button {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; white-space: nowrap;
}
.btn:hover, button:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover, button.primary:hover { filter: brightness(1.06); }
.btn.danger, button.danger { color: var(--bad); }
.btn.sm, button.sm { padding: 4px 10px; font-size: 13px; }
.btn.ghost, button.ghost { border-color: transparent; background: transparent; }
button[disabled] { opacity: .5; cursor: not-allowed; }
form.inline-form { display: inline; }

/* ---------- Flash ---------- */
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--good-soft); color: var(--good); }
.flash.err { background: var(--bad-soft); color: var(--bad); }

/* ---------- Tabs / pager ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 0 0; }

/* ---------- Question preview ---------- */
.q-text { white-space: pre-wrap; word-break: break-word; }
.q-text pre { white-space: pre; }
.q-opts { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.q-opts li { padding: 4px 8px; border-radius: 6px; white-space: pre-wrap; }
.q-opts li.right { background: var(--good-soft); color: var(--good); font-weight: 600; }
.q-expl { margin-top: 8px; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
details summary { cursor: pointer; color: var(--accent); font-weight: 600; font-size: 13px; }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 34px; }

dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.meta dt { color: var(--muted); }
dl.meta dd { margin: 0; font-weight: 500; }

/* ---------- Login ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; }
.login .brand { padding: 0 0 18px; }
.steps { padding-left: 18px; margin: 8px 0 0; color: var(--muted); }
.or { text-align: center; color: var(--muted); margin: 18px 0; font-size: 13px; }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 16px; align-items: center; border-right: 0; border-bottom: 1px solid var(--border); }
    .brand { padding: 0 8px 0 0; }
    .brand small { display: none; }
    .nav { display: flex; flex-wrap: wrap; gap: 2px; width: 100%; }
    .nav a { padding: 6px 8px; font-size: 14px; }
    .side .spacer { display: none; }
    .side form { margin-left: auto; }
    main { padding: 18px 16px 48px; }
    .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid.k3, .grid.k2, .grid.side-r, .row, .row.k3, .row.k4 { grid-template-columns: 1fr; }
    .filters input[type=search] { min-width: 0; }
}

/* =================== O'quvchi web (/app) =================== */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar .in { max-width: 820px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .brand { padding: 0; }
.topbar nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.topbar nav a { padding: 7px 10px; border-radius: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
.topbar nav a:hover { background: var(--surface-2); text-decoration: none; }
.topbar nav a.on { background: var(--accent-soft); color: var(--accent); }
.wrap { max-width: 820px; margin: 0 auto; padding: 20px 16px 60px; }
.hello { margin: 4px 0 18px; }
.hello h1 { font-size: 22px; }
.list-item { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .t { font-weight: 600; }

.q-card { font-size: 17px; }
.q-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.q-body { white-space: pre-wrap; word-break: break-word; line-height: 1.55; }
.q-body pre { white-space: pre; font-size: 14px; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress span { display: block; height: 100%; background: var(--accent); }
.answers { display: grid; gap: 10px; margin-top: 18px; }
.answers form { margin: 0; }
.opt-btn { width: 100%; justify-content: flex-start; text-align: left; white-space: normal; padding: 14px 16px; font-size: 16px; font-weight: 500; gap: 12px; border-radius: 12px; line-height: 1.4; }
.opt-btn .l { flex: 0 0 32px; height: 32px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; }
.opt-btn:hover .l { background: var(--accent); color: var(--accent-ink); }
.opt-btn .tx { white-space: pre-wrap; word-break: break-word; }
.opt { display: flex; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; align-items: flex-start; }
.opt .l { flex: 0 0 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; }
.opt .tx { white-space: pre-wrap; word-break: break-word; }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.right .l { background: var(--good); color: #fff; }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .l { background: var(--bad); color: #fff; }
.verdict { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.explain { margin-top: 14px; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); white-space: pre-wrap; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; }
.timer.low { color: var(--bad); }
.score { font-size: 46px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.center-text { text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { margin: 0; font-weight: 500; border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.chips label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.me-row td { font-weight: 700; background: var(--accent-soft); }
@media (max-width: 600px) {
    .topbar nav { width: 100%; margin-left: 0; }
    .topbar nav a { padding: 6px 8px; font-size: 13px; }
    .q-card { font-size: 16px; }
}
@media (max-width: 900px) {
    .wrap .grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
    .wrap .grid.k3 .card { padding: 12px 10px; }
    .wrap .kpi .num { font-size: 20px; }
    .wrap .kpi .lbl { font-size: 11px; line-height: 1.3; }
}
