:root {
  --bg: #0d1117;
  --bg-soft: #131a24;
  --card: #172029;
  --card-hover: #1d2733;
  --border: #26313d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #2f81f7;
  --accent-hover: #4b95ff;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 15% -10%, #1b2a3f 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .4rem; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .6rem; }

.container { width: min(1120px, 100% - 2rem); margin-inline: auto; }
.main { flex: 1; padding: 1.8rem 0 3rem; }
.muted { color: var(--muted); }
.small { font-size: .87rem; }

/* ---------- Topbar ---------- */
.topbar {
  background: rgba(13, 17, 23, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 1.2rem; padding: .7rem 0; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.brand small { font-weight: 400; color: var(--muted); font-size: .72rem; }
.brand-mark { font-size: 1.6rem; }
.nav { display: flex; align-items: center; gap: .3rem; margin-left: auto; flex-wrap: wrap; }
.nav > a { padding: .45rem .8rem; border-radius: 9px; color: var(--muted); }
.nav > a:hover { background: var(--card); color: var(--text); }
.nav > a.btn-primary { color: #fff; }

.user-box { position: relative; }
.user-box details summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: .5rem;
  padding: .3rem .5rem; border-radius: 9px;
}
.user-box details summary::-webkit-details-marker { display: none; }
.user-box details summary:hover { background: var(--card); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: .85rem;
}
.user-name { font-size: .9rem; }
.menu {
  position: absolute; right: 0; top: calc(100% + .4rem); min-width: 200px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: .35rem; display: grid; gap: .15rem;
}
.menu a, .link-btn {
  display: block; width: 100%; text-align: left; padding: .5rem .7rem; border-radius: 8px;
  background: none; border: none; color: var(--text); font: inherit; cursor: pointer;
}
.menu a:hover, .link-btn:hover { background: var(--card-hover); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .5rem .95rem; border-radius: 10px; border: 1px solid transparent;
  font-weight: 600; font-size: .9rem; cursor: pointer; transition: .15s;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--card); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--card-hover); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(248, 81, 73, .12); }
.btn-block { width: 100%; }

/* ---------- Cards / layout ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.25rem;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem;
}
.head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.section-title { margin: 2rem 0 1rem; }
.back-bar {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap; margin-bottom: .9rem;
}
.back-bar .breadcrumb { margin-bottom: 0; }
.back-btn {
  display: inline-flex; align-items: center; gap: .35rem; flex: none;
  padding: .38rem .75rem; border-radius: 9px;
  background: var(--card); border: 1px solid var(--border);
  color: var(--muted); font-size: .85rem; font-weight: 600; transition: .15s;
}
.back-btn:hover { background: var(--card-hover); color: var(--text); border-color: #33445a; }
.back-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.back-btn svg { width: 15px; height: 15px; }

.breadcrumb { color: var(--muted); font-size: .87rem; margin-bottom: .8rem; }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span { margin: 0 .35rem; }

.search { display: flex; gap: .5rem; margin-bottom: 1.4rem; }
.search .input { max-width: 420px; }

.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.course-card { position: relative; transition: .15s; display: block; }
.course-card:hover { background: var(--card-hover); transform: translateY(-2px); border-color: #33445a; }
.course-badge {
  position: absolute; top: 1rem; right: 1rem; font-size: .75rem;
  background: rgba(47, 129, 247, .15); color: #7cb3ff; padding: .15rem .55rem; border-radius: 99px;
}
.card-link { color: var(--accent); font-size: .88rem; font-weight: 600; }

.lesson-card { padding: 0; overflow: hidden; transition: .15s; }
.lesson-card:hover { background: var(--card-hover); transform: translateY(-2px); }
.thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; background: #0b0f14; }
.thumb-empty { display: grid; place-items: center; font-size: 2rem; }
.lesson-card-body { padding: .85rem 1rem 1rem; }
.lesson-card-body h3 { font-size: 1rem; margin: .35rem 0 .2rem; }

.pill {
  display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 99px;
  background: rgba(63, 185, 80, .13); color: #6fd18a;
}
.pill-file { background: rgba(255, 196, 0, .12); color: #e3b341; }

.lesson-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.lesson-row { display: flex; align-items: center; gap: 1rem; padding: .8rem 1rem; }
.lesson-row:hover { background: var(--card-hover); }
.order-badge {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  background: var(--bg-soft); border: 1px solid var(--border); font-size: .85rem; color: var(--muted);
}
.row-thumb { flex: none; width: 112px; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: #0b0f14; }
.lesson-row-body { flex: 1; min-width: 0; }
.lesson-title { font-weight: 600; }
.lesson-title:hover { color: var(--accent); }
.meta { font-size: .8rem; color: var(--muted); margin: .2rem 0 0; }

.video-wrap {
  position: relative; aspect-ratio: 16/9; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: #000; box-shadow: var(--shadow); margin-bottom: 1.2rem;
}
.video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-el { position: absolute; inset: 0; width: 100%; height: 100%; background: #000; }

.link-card { text-align: center; padding: 2.5rem 1rem; }
.link-card .empty-icon { font-size: 2.2rem; margin-bottom: .3rem; }
.link-url { word-break: break-all; margin-top: .8rem; }
.pill-kind { background: rgba(163, 113, 247, .14); color: #c297ff; }

.two-col { display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; align-items: start; }
.side h2 { margin-top: 1rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.side h2:first-child { margin-top: 0; }
.file-link { display: block; color: var(--accent); word-break: break-all; padding: .3rem 0; }
.prose { white-space: normal; }
.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 1.5rem; }

.empty { text-align: center; padding: 3rem 1rem; }
.empty-icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* ---------- Progress / planned state ---------- */
.progress {
  height: 6px; border-radius: 99px; background: var(--bg-soft);
  border: 1px solid var(--border); overflow: hidden; margin: .5rem 0 .2rem;
}
.progress-bar { height: 100%; background: var(--success); border-radius: 99px; }
.pill-planned { background: rgba(227, 179, 65, .13); color: #e3b341; }
.lesson-row-planned { opacity: .82; }
.lesson-row-planned .row-thumb.thumb-empty { background: var(--bg-soft); }

/* ---------- Quarter / topic list (grade detail) ---------- */
.quarter-block + .quarter-block { margin-top: 1rem; }
.quarter-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .8rem;
}
.quarter-head h2 { font-size: 1.05rem; }
.topic-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.topic-row {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .6rem; border-radius: 9px;
}
.topic-row:hover { background: var(--bg-soft); }
.topic-row.topic-planned .topic-title { color: var(--muted); }
.topic-main { flex: 1; display: grid; gap: .1rem; min-width: 0; }
.plan-note {
  display: block; font-size: .76rem; color: var(--muted);
  margin: .1rem 0 0; font-family: Consolas, "Courier New", monospace;
}
.topic-title { flex: 1; font-weight: 500; }
.topic-title:hover { color: var(--accent); }
.inline-link { color: var(--accent); text-decoration: underline; }

.radio-field {
  border: 1px solid var(--border); border-radius: 12px;
  padding: .9rem 1rem; margin: 0; display: grid; gap: .5rem;
  background: var(--bg-soft);
}
.radio-field legend {
  padding: 0 .4rem; font-size: .82rem; font-weight: 600; color: var(--muted);
}
.radio-row {
  display: flex; align-items: flex-start; gap: .55rem;
  cursor: pointer; font-size: .9rem; line-height: 1.4;
}
.radio-row input[type="radio"] {
  margin-top: .15rem; width: 16px; height: 16px; accent-color: var(--accent); flex: none;
}

/* ---------- Yillik reja jadvali ---------- */
.plan-table td { vertical-align: top; }
.plan-table .col-num { width: 46px; text-align: center; color: var(--muted); }
.plan-table .col-note { width: 210px; }
.plan-table .col-status { width: 110px; }
.plan-table .col-dl { width: 40px; text-align: center; }
.plan-table .col-dl a { font-size: 1rem; opacity: .45; transition: .15s; }
.plan-table .col-dl a:hover { opacity: 1; }
.plan-table tbody tr:hover > * { background: var(--card-hover); }
.plan-table a { color: var(--text); font-weight: 500; }
.plan-table a:hover { color: var(--accent); }
.quarter-row td {
  background: var(--bg-soft); font-weight: 700; letter-spacing: .02em;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
}
.quarter-row:hover > * { background: var(--bg-soft) !important; }

@media print {
  .topbar, .footer, .no-print, .back-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .table-card { border: 0; background: #fff; box-shadow: none; padding: 0; }
  .main { padding: 0; }
  .container { width: 100%; }
  .table { min-width: 0; font-size: 11pt; }
  .table thead th { background: #eee !important; color: #000; }
  .plan-table a { color: #000; text-decoration: none; }
  .quarter-row td { background: #f0f0f0 !important; color: #000; }
  .muted, .plan-table .col-note { color: #444 !important; }
  .pill, .lang-badge { border: 1px solid #999; color: #000 !important; background: none !important; }
  tr { page-break-inside: avoid; }
}

.import-part {
  border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem 1rem; margin-bottom: .7rem; background: var(--bg-soft);
}
.import-part-head {
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap; margin-bottom: .4rem;
}
.import-part .preview-list { margin-bottom: 0; }

.preview-list {
  margin: .4rem 0 1rem; padding-left: 1.4rem;
  display: grid; gap: .25rem; font-size: .9rem;
}
.preview-list li { color: var(--text); }

.code-sample {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; margin: .2rem 0 1rem; overflow-x: auto;
  font-family: Consolas, "Courier New", monospace; font-size: .8rem;
  color: var(--text); white-space: pre; line-height: 1.5;
}
.side code {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 4px; padding: .05rem .3rem; font-size: .82rem;
}

/* ---------- Grade card ---------- */
.grade-cell { display: flex; flex-direction: column; }
.grade-cell .grade-card { flex: 1; }
.grade-card-links {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .3rem 0; font-size: .82rem;
}
.grade-card-links a { color: var(--muted); }
.grade-card-links a:hover { color: var(--accent); }
.dot-sep { color: var(--border); }

.grade-card {
  display: flex; flex-direction: column; gap: .7rem;
  position: relative; overflow: hidden; transition: transform .18s, border-color .18s;
}
.grade-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), #a371f7);
  opacity: 0; transition: opacity .18s;
}
.grade-card:hover { transform: translateY(-3px); border-color: #33445a; }
.grade-card:hover::before { opacity: 1; }

.grade-top { display: flex; align-items: center; gap: .75rem; }
.grade-top-text { flex: 1; min-width: 0; }
.grade-top-text h2 { margin: 0; font-size: 1.15rem; }
.grade-num {
  flex: none; width: 46px; height: 46px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.3rem; font-weight: 700;
  color: #7cb3ff; background: rgba(47, 129, 247, .13); border: 1px solid rgba(47, 129, 247, .28);
}
.grade-count {
  flex: none; align-self: flex-start; font-size: .72rem; color: var(--muted);
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: .12rem .5rem; border-radius: 99px;
}
.grade-stat { margin-top: auto; }
.grade-stat p { margin: 0; }

.plan-btn {
  display: flex; align-items: center; justify-content: center;
  padding: .55rem .9rem; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border);
  font-weight: 600; font-size: .88rem; color: var(--text); transition: .18s;
}
.grade-card:hover .plan-btn {
  background: var(--accent); border-color: var(--accent); color: #fff;
}

/* ---------- Til tanlagichi va belgilari ---------- */
.lang-tabs { display: flex; gap: .4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.lang-tab {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .45rem .9rem; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border);
  font-size: .88rem; font-weight: 600; color: var(--muted); transition: .15s;
}
.lang-tab:hover { background: var(--card-hover); color: var(--text); }
.lang-tab.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.lang-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border); border: 1px solid var(--muted);
}
.lang-dot-ok { background: var(--success); border-color: var(--success); }
.lang-tab.is-active .lang-dot { border-color: rgba(255, 255, 255, .6); }
.lang-tab.is-active .lang-dot-ok { background: #fff; border-color: #fff; }

.lang-badges { display: inline-flex; gap: .25rem; vertical-align: middle; }
.lang-badge {
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: .1rem .38rem; border-radius: 5px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--muted);
}
.lang-badge.is-on {
  background: rgba(63, 185, 80, .13); border-color: rgba(63, 185, 80, .4); color: #6fd18a;
}
.pill-lang { background: rgba(163, 113, 247, .14); color: #c297ff; }

/* Formadagi til bo'limlari */
.lang-block {
  border: 1px solid var(--border); border-radius: 12px;
  padding: 1rem 1.1rem; margin: 0; display: grid; gap: 1rem;
  background: var(--bg-soft);
}
.lang-block legend {
  padding: .15rem .6rem; margin-left: -.2rem;
  font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--border); border-radius: 99px;
}
.form-note { margin: 0; }

/* ---------- Ustozlar jadvali ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 640px; }
.table th, .table td { padding: .7rem .9rem; text-align: left; vertical-align: middle; }
.table thead th {
  background: var(--bg-soft); color: var(--muted);
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--card-hover); }
.row-blocked { opacity: .5; }
.row-actions { display: flex; gap: .4rem; justify-content: flex-end; align-items: center; }
.row-actions form { margin: 0; }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.pill-admin { background: rgba(47, 129, 247, .15); color: #7cb3ff; }
.pill-blocked { background: rgba(248, 81, 73, .13); color: #ff8079; margin-left: .35rem; }

.check-field {
  display: flex; flex-direction: row; align-items: center;
  gap: .5rem; flex-wrap: wrap;
}
.check-field input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.check-field .help, .check-field .error { flex-basis: 100%; }

/* ---------- Attachment viewer ---------- */
.doc-card { margin-top: 1rem; }
.doc-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: .9rem;
}
.doc-head h2 { font-size: 1rem; word-break: break-all; }
.doc-frame {
  width: 100%; height: min(78vh, 900px); border: 1px solid var(--border);
  border-radius: 10px; background: #fff; display: block;
}
.doc-image {
  width: 100%; height: auto; border: 1px solid var(--border);
  border-radius: 10px; display: block; background: #0b0f14;
}
.doc-fallback {
  text-align: center; padding: 2.2rem 1rem;
  border: 1px dashed var(--border); border-radius: 10px; background: var(--bg-soft);
}
.doc-fallback p { margin: .3rem 0; }

@media (max-width: 760px) {
  .doc-frame { height: 65vh; }
}

/* ---------- Forms ---------- */
.form-card { max-width: 720px; }
.form { display: grid; gap: 1rem; }
.field { display: grid; gap: .35rem; }
.field > span, .field > label { font-size: .87rem; color: var(--muted); font-weight: 600; }
.req { color: var(--danger); }
.input {
  width: 100%; padding: .6rem .75rem; border-radius: 10px;
  background: var(--bg-soft); border: 1px solid var(--border); color: var(--text);
  font: inherit; transition: .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 129, 247, .18); }
textarea.input { resize: vertical; }
select.input option { background: var(--bg-soft); }
.help { color: var(--muted); font-size: .78rem; }

/* Parolni ko'rsatish/yashirish tugmasi */
.password-field { position: relative; }
.password-field .input { padding-right: 2.9rem; }
.password-toggle {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center; width: 32px; height: 32px; padding: 0;
  background: none; border: 0; border-radius: 8px;
  color: var(--muted); cursor: pointer; transition: .15s;
}
.password-toggle:hover { color: var(--text); background: var(--card-hover); }
.password-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.password-toggle svg { width: 18px; height: 18px; display: block; }
.password-toggle .icon-eye-off { display: none; }
.password-toggle.is-revealed .icon-eye { display: none; }
.password-toggle.is-revealed .icon-eye-off { display: block; }
.error { color: var(--danger); font-size: .8rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.messages { display: grid; gap: .5rem; margin-bottom: 1.2rem; }
.alert { padding: .65rem .9rem; border-radius: 10px; border: 1px solid var(--border); background: var(--card); font-size: .9rem; }
.alert-success { border-color: rgba(63, 185, 80, .5); background: rgba(63, 185, 80, .1); }
.alert-error { border-color: rgba(248, 81, 73, .5); background: rgba(248, 81, 73, .1); }
.alert-warning { border-color: rgba(227, 179, 65, .5); background: rgba(227, 179, 65, .1); }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 78vh; display: grid; place-items: center; }
.auth-card {
  width: min(420px, 100%); background: var(--card); border: 1px solid var(--border);
  border-radius: 18px; padding: 2rem; text-align: center; box-shadow: var(--shadow);
}
.auth-card .form { text-align: left; margin-top: 1.3rem; }
.auth-logo { font-size: 2.6rem; }
.auth-card h1 { font-size: 1.3rem; }
.auth-note { margin-top: 1.2rem; font-size: .8rem; color: var(--muted); }

.footer { border-top: 1px solid var(--border); padding: 1.2rem 0; color: var(--muted); font-size: .82rem; }

@media (max-width: 760px) {
  .two-col { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  .nav { width: 100%; order: 3; }
  .user-box { margin-left: auto; }
  .row-thumb { display: none; }
  h1 { font-size: 1.4rem; }
}
