:root {
    --bg: #131210;
    --surface: #1b1a17;
    --surface-2: #24221e;
    --border: #34312b;
    --border-hover: #4a463e;
    --text: #ece6da;
    --muted: #9b9385;
    --accent: #e3a23c;
    --accent-hover: #f0b357;
    --accent-ink: #1d1406;
    --accent-soft: rgba(227, 162, 60, 0.18);
    --success: #6fbf73;
    --warning: #e3a23c;
    --danger: #e5685a;
    --radius: 10px;
    --topbar: rgba(19, 18, 16, 0.92);
    --hover: #2c2924;
    --row-hover: rgba(255, 255, 255, 0.025);
    --dot: #5a554c;
    --alert-text: #f4a196;
    color-scheme: dark;
}
[data-theme="light"] {
    --bg: #f4f1ea;
    --surface: #fbf9f4;
    --surface-2: #ece7dc;
    --border: #ddd5c6;
    --border-hover: #c6bca9;
    --text: #26221b;
    --muted: #6f675a;
    --accent: #b97a14;
    --accent-hover: #a06a10;
    --accent-ink: #fffaf0;
    --accent-soft: rgba(185, 122, 20, 0.18);
    --success: #3f8f4a;
    --warning: #b97a14;
    --danger: #c4473a;
    --topbar: rgba(244, 241, 234, 0.92);
    --hover: #e4ddcf;
    --row-hover: rgba(0, 0, 0, 0.025);
    --dot: #bdb3a2;
    --alert-text: #a8372b;
    color-scheme: light;
}
body { transition: background .2s, color .2s; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    background: var(--topbar);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar__inner {
    max-width: 1080px; margin: 0 auto; padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: -0.01em; }
.brand__mark {
    width: 28px; height: 28px; border-radius: 6px; background: var(--accent);
    display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--accent-ink);
}
.brand__sub { color: var(--muted); font-weight: 400; }
.userbox { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.userbox__name { font-weight: 500; }
.userbox__login { color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px; border-radius: 6px;
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--border-hover); background: var(--hover); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--block { width: 100%; height: 40px; }
.btn[disabled] { opacity: .6; cursor: default; }

/* ---------- layout ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { color: var(--muted); margin-top: 4px; }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 32px; }
.metric { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.metric__label { color: var(--muted); font-size: 13px; }
.metric__value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.metric__value small { font-size: 14px; color: var(--muted); font-weight: 400; }

/* ---------- section ---------- */
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.section__head { padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border); }
.section__title { font-size: 17px; font-weight: 600; }
.section__meta { color: var(--muted); font-size: 13px; margin-top: 2px; }
.section__stat { text-align: right; min-width: 180px; }
.section__stat-text { font-size: 13px; color: var(--muted); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.section--soon { opacity: .55; }
.section--soon .section__head { border-bottom: none; }
/* ochiladigan/yopiladigan bo'lim */
.section__toggle {
    width: 100%; background: none; border: none; border-bottom: 1px solid var(--border);
    color: inherit; text-align: left; cursor: pointer; font: inherit;
    justify-content: flex-start; transition: background .15s, border-color .2s;
}
.section__toggle:hover { background: var(--row-hover); }
.section__toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.section:not(.is-open) .section__toggle { border-bottom-color: transparent; }
.section__info { flex: 1; min-width: 0; }
.chevron {
    flex: none; width: 9px; height: 9px; margin: 0 4px 0 2px;
    border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
    transform: rotate(-45deg); transition: transform .2s;
}
.section.is-open .chevron { transform: rotate(45deg); border-color: var(--accent); }
.section__body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s ease; }
.section__body > .topics { overflow: hidden; }
.section.is-open .section__body { grid-template-rows: 1fr; }

.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }

.bar { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar__fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s; }
.bar__fill--done { background: var(--success); }

/* ---------- topic rows ---------- */
.topics { list-style: none; }
.topic {
    display: grid; grid-template-columns: 56px 1fr 200px 130px 120px; align-items: center; gap: 16px;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.topic:last-child { border-bottom: none; }
.topic:hover { background: var(--row-hover); }
.topic__code { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 14px; }
.topic__title { font-weight: 500; }
.topic__progress { display: flex; flex-direction: column; gap: 6px; }
.topic__count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); }
.status--done { color: var(--success); }
.status--done::before { background: var(--success); }
.status--active { color: var(--warning); }
.status--active::before { background: var(--warning); }
.topic .btn { justify-self: end; width: 110px; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth__card { width: 100%; max-width: 380px; }
.auth__brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 24px; font-weight: 600; font-size: 17px; }
.auth__panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.auth__title { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.auth__hint { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field input {
    width: 100%; height: 38px; padding: 0 12px; border-radius: 6px;
    background: var(--bg); border: 1px solid var(--border); color: var(--text); font-size: 14px;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field small { display: block; color: var(--muted); font-size: 12px; margin-top: 5px; }
.alert { display: none; background: rgba(229, 104, 90, .1); border: 1px solid rgba(229, 104, 90, .4); color: var(--alert-text); border-radius: 6px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.alert.show { display: block; }
.auth__switch { text-align: center; color: var(--muted); font-size: 14px; margin-top: 16px; }
.auth__switch a { color: var(--accent); cursor: pointer; }
.auth__switch a:hover { text-decoration: underline; }

.loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ---------- nav + theme toggle ---------- */
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 6px; color: var(--muted); font-size: 14px; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--row-hover); }
.nav a.is-active { color: var(--text); background: var(--surface-2); }
.userbox__name:hover { color: var(--accent); }
.theme-btn { width: 34px; padding: 0; }
.theme-btn svg { width: 16px; height: 16px; }
.theme-btn .ico-sun { display: none; }
[data-theme="light"] .theme-btn .ico-sun { display: block; }
[data-theme="light"] .theme-btn .ico-moon { display: none; }
.auth__theme { position: fixed; top: 16px; right: 16px; }

/* ---------- profile ---------- */
.profile-head {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; margin-bottom: 20px;
}
.avatar {
    width: 72px; height: 72px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
    border: 2px solid var(--accent); display: grid; place-items: center; font-size: 26px; font-weight: 700;
}
.profile-name { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.profile-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.level { margin-top: 14px; max-width: 460px; }
.level__row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.level__badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
    background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600;
}
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.panel__head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.panel__title { font-size: 16px; font-weight: 600; }
.panel__meta { color: var(--muted); font-size: 13px; }
.panel__body { padding: 16px 20px; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.badge {
    display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 8px;
    border: 1px solid var(--border); background: var(--bg);
}
.badge__icon {
    flex: none; width: 36px; height: 36px; border-radius: 8px; display: grid; place-items: center;
    background: var(--surface-2); color: var(--muted); font-size: 17px; font-weight: 700;
}
.badge__name { font-size: 14px; font-weight: 600; }
.badge__desc { font-size: 12px; color: var(--muted); }
.badge--locked { opacity: .5; }
.badge--earned { border-color: var(--accent); }
.badge--earned .badge__icon { background: var(--accent); color: var(--accent-ink); }
.ladder { list-style: none; display: grid; gap: 8px; }
.ladder li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center; font-size: 14px; color: var(--muted); }
.ladder li::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); justify-self: center; }
.ladder li.is-reached { color: var(--text); }
.ladder li.is-reached::before { background: var(--success); }
.ladder li.is-current { color: var(--accent); font-weight: 600; }
.ladder li.is-current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.ladder small { font-variant-numeric: tabular-nums; }
.breakdown { display: grid; gap: 14px; }
.breakdown__row { display: grid; grid-template-columns: 180px 1fr 90px; gap: 14px; align-items: center; font-size: 14px; }
.breakdown__row span:last-child { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
.heat i { border-radius: 3px; background: var(--surface-2); position: relative; }
.heat i::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--accent); opacity: 0; }
.heat i.l1::after { opacity: .35; } .heat i.l2::after { opacity: .55; } .heat i.l3::after { opacity: .78; } .heat i.l4::after { opacity: 1; }
.heat i.future { visibility: hidden; }
.heat-legend { display: flex; align-items: center; gap: 4px; justify-content: flex-end; font-size: 12px; color: var(--muted); margin-top: 8px; }
.heat-legend .heat { display: flex; grid-template-rows: none; }
.heat-legend i { width: 11px; height: 11px; }
.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; font-size: 13px; color: var(--muted); }
.facts b { display: block; color: var(--text); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

@media (max-width: 820px) {
    .two-col { grid-template-columns: 1fr; }
    .breakdown__row { grid-template-columns: 1fr 80px; }
    .breakdown__row .bar { grid-column: 1 / -1; grid-row: 2; }
    .nav a { padding: 6px 8px; }
    .brand__sub { display: none; }
    .summary { grid-template-columns: repeat(2, 1fr); }
    .topic { grid-template-columns: 44px 1fr 110px; row-gap: 10px; }
    .topic__progress { grid-column: 2 / 3; }
    .topic .status { grid-column: 3; grid-row: 1; justify-self: end; }
    .topic .btn { grid-column: 3; grid-row: 2; }
    .section__head { flex-direction: column; align-items: flex-start; }
    .section__toggle { flex-direction: row; flex-wrap: wrap; align-items: center; }
    .section__toggle .section__stat { flex-basis: 100%; padding-left: 26px; }
    .section__stat { text-align: left; width: 100%; }
    .userbox__login { display: none; }
}
