:root {
  --bg: #f3f3f3; --card: #fbfbfb; --border: #e5e5e5; --text: #1a1a1a; --muted: #5d5d5d;
  --brand: #005fb8; --brand-dark: #004a91; --blue: #0284c7; --red: #d32f2f; --orange: #ea580c;
  --tg: #229ed9; --tg-dark: #1b8bc0; --chip: #e8efe9; --chip-text: #1a1a1a; --pick: #fff4ce;
  --row-alt: #f3f3f3; --row: #ffffff; --lesson-tint: #e8f5e9; --hw-tint: #e3f2fd; --ok: #0f7b0f;
  --input: #ffffff; --shadow: 0 2px 10px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202020; --card: #2b2b2b; --border: #3a3a3a; --text: #f2f2f2; --muted: #b5b5b5;
    --brand: #4cc2ff; --brand-dark: #2fa8e8; --blue: #38bdf8; --chip: #3a3d3b; --chip-text: #f2f2f2;
    --pick: #4a3f1a; --row-alt: #262626; --row: #2b2b2b; --lesson-tint: #1f3324; --hw-tint: #1c2d3d;
    --ok: #6ccb5f; --input: #1f1f1f; --shadow: 0 2px 10px rgba(0,0,0,.4);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }

/* sarlavha */
.top { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.top h1 { font-size: 17px; margin: 0; font-weight: 600; flex: 1; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.top .who { color: var(--muted); font-size: 13px; white-space: nowrap; }
.link { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link:hover { background: rgba(0,95,184,.08); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 16px 20px 120px; }

/* tugmalar */
.btn { border: 0; border-radius: 999px; padding: 7px 16px; cursor: pointer; font-weight: 600; background: var(--chip);
  color: var(--chip-text); white-space: nowrap; transition: filter .12s; }
.btn:hover { filter: brightness(.95); }
.btn:disabled { opacity: .45; cursor: default; filter: none; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.blue { background: var(--blue); color: #fff; }
.btn.tg { background: var(--tg); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.sm { padding: 4px 12px; font-size: 13px; }
.btn.block { width: 100%; }

/* kirish */
.login { max-width: 360px; margin: 10vh auto; background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 28px; box-shadow: var(--shadow); }
.login h2 { margin: 0 0 4px; font-size: 20px; }
.login p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 13px; margin-bottom: 4px; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--input); }
.input:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; margin: 4px 0 8px; }

/* guruhlar */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px; cursor: pointer;
  transition: border-color .12s; }
.card:hover { border-color: var(--brand); }
.card h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.card .sub { color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }

/* bo'lim tablari */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; border: 0; border-radius: 999px; padding: 9px 12px; font-weight: 600; cursor: pointer;
  background: #e2e8f0; color: var(--text); }
@media (prefers-color-scheme: dark) { .tab { background: #333; } }
.tab.on.lesson { background: var(--brand); color: #fff; }
.tab.on.homework { background: var(--blue); color: #fff; }

/* boshqaruv qatori */
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-bottom: 6px; }
.controls label { font-weight: 600; font-size: 13px; }
.controls .grp { display: flex; align-items: center; gap: 6px; }
.controls input[type=text] { min-width: 200px; }
.controls select, .controls input { padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--input); }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; color: var(--muted); font-size: 13px;
  user-select: none; }
.switch i { width: 34px; height: 18px; border-radius: 9px; border: 1px solid #8a8a8a; position: relative;
  background: var(--card); transition: .15s; }
.switch i::after { content: ""; position: absolute; width: 10px; height: 10px; border-radius: 50%; top: 3px; left: 4px;
  background: #5d5d5d; transition: .15s; }
.switch.on { color: var(--text); }
.switch.on i { background: var(--brand); border-color: var(--brand); }
.switch.on i::after { left: 19px; background: #fff; }
.hint { color: var(--muted); font-size: 12.5px; margin: 2px 0 6px; }
.summary { display: flex; align-items: center; gap: 8px; border-radius: 6px; padding: 6px 10px; margin-bottom: 6px;
  font-weight: 600; font-size: 13.5px; }
.summary.lesson { background: var(--lesson-tint); color: var(--brand); }
.summary.homework { background: var(--hw-tint); color: var(--blue); }
.summary span { flex: 1; text-align: center; }

/* o'quvchilar qatorlari */
.rows { background: var(--card); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.row { display: grid; grid-template-columns: 34px minmax(160px, 260px) minmax(300px, 3fr) auto minmax(120px, 2fr);
  align-items: center; gap: 6px; padding: 3px 8px 3px 0; background: var(--row); border: 2px solid transparent; }
.row:nth-child(even) { background: var(--row-alt); }
.row.picked { background: var(--pick); }
.row.cursor { border-color: var(--brand); }
.row .no { text-align: right; color: var(--muted); font-size: 12.5px; }
.row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .name.absent { color: var(--red); }
.scores { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; }
.sc, .chip { border: 0; border-radius: 999px; padding: 3px 0; font-weight: 700; cursor: pointer; background: var(--chip);
  color: var(--chip-text); font-size: 13px; }
.chip { padding: 3px 10px; white-space: nowrap; }
.sc:disabled, .chip:disabled { opacity: .4; cursor: default; }
.extras { display: flex; gap: 3px; }
.chip.absent-on { background: var(--red); color: #fff; }
.chip.la-on { background: var(--orange); color: #fff; }
.row .comment { width: 100%; padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--input); }
.sep { height: 2px; background: var(--brand); margin: 2px 0 4px; }

/* Testlar, Umumiy o'zlashtirish, Harakat */
.tabs { flex-wrap: wrap; }
.tab.on.test { background: var(--brand); color: #fff; }
.tab.on.overall { background: #7c3aed; color: #fff; }
.tab.on.trend { background: #0891b2; color: #fff; }
.summary.test { background: var(--lesson-tint); color: var(--brand); }
.summary.overall { background: #f3e8ff; color: #6d28d9; }
.summary.trend { background: #ecfeff; color: #0e7490; }
@media (prefers-color-scheme: dark) {
  .summary.overall { background: #2e1f47; color: #c4b5fd; }
  .summary.trend { background: #133037; color: #67e8f9; }
}
.row.overall { grid-template-columns: 34px minmax(160px, 260px) 170px minmax(260px, 3fr) minmax(120px, 2fr); }
.row.trend { grid-template-columns: 34px minmax(160px, 260px) minmax(420px, 4fr) minmax(120px, 2fr); }
.row.test { grid-template-columns: 34px minmax(160px, 260px) minmax(200px, 3fr) auto minmax(120px, 2fr); }
.battery { position: relative; height: 20px; border: 2px solid #94a3b8; border-radius: 5px; overflow: hidden; margin-right: 10px; }
.battery::after { content: ""; position: absolute; right: -6px; top: 4px; width: 4px; height: 8px; background: #94a3b8;
  border-radius: 0 2px 2px 0; }
.battery i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; transition: width .15s; }
.battery span { position: relative; display: block; text-align: center; font-size: 12px; font-weight: 700; line-height: 16px; }
.levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.lv { border: 0; border-radius: 999px; padding: 4px 6px; font-weight: 700; cursor: pointer; background: #eef2f6;
  font-size: 12.5px; line-height: 1.2; white-space: normal; }
@media (prefers-color-scheme: dark) { .lv { background: #33363a; } }
.tests-cfg { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 2px 0 6px; }
.test-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 4px 8px; font-size: 13px; color: var(--muted); }
.test-chip b { color: var(--brand); }
.test-chip input { padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--input); }
.test-chip .tname { width: 150px; }
.test-chip .tnum { width: 60px; text-align: center; }
.tcells { display: flex; gap: 12px; flex-wrap: wrap; }
.tcell { display: inline-flex; align-items: center; gap: 6px; }
.tin { width: 64px; padding: 4px 6px; text-align: center; border: 1px solid var(--border); border-radius: 6px;
  background: var(--input); }
.tin.bad { border-color: var(--red); outline: 1px solid var(--red); }
.tin:disabled { opacity: .4; }
.tpct { min-width: 92px; font-weight: 700; font-size: 12.5px; }

/* pastki panel */
.bottom { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border);
  padding: 10px 20px; z-index: 6; }
.bottom .in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.bottom .status { color: var(--muted); font-size: 13px; flex: 1; min-width: 140px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* xabarlar */
.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #e6f4ea; color: #0f5c2e;
  border: 1px solid #0f7b0f; border-radius: 8px; padding: 9px 16px; font-weight: 600; z-index: 30;
  display: flex; gap: 12px; align-items: center; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast.info { background: #e8f1fb; color: #0b4a8b; border-color: #005fb8; }
.toast.error { background: #fdecea; color: #8a1c1c; border-color: #d32f2f; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: center;
  justify-content: center; z-index: 40; padding: 16px; }
.modal { background: var(--card); border-radius: 10px; padding: 22px; max-width: 440px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 8px; font-size: 16px; }
.modal p { margin: 0 0 18px; white-space: pre-line; color: var(--text); }
.modal .acts { display: flex; justify-content: flex-end; gap: 8px; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 6px 0 14px; }
.progress div { height: 100%; background: var(--tg); width: 0; transition: width .2s; }

/* telefon */
@media (max-width: 760px) {
  .top { padding: 10px 14px; }
  .wrap { padding: 12px 10px 150px; }
  .row { grid-template-columns: 26px 1fr auto; grid-template-areas: "no name extras" "sc sc sc" "cm cm cm";
    padding: 6px 8px 8px 0; row-gap: 5px; }
  .row .no { grid-area: no; }
  .row .name { grid-area: name; white-space: normal; }
  .row .scores { grid-area: sc; padding-left: 8px; }
  .row .extras { grid-area: extras; }
  .row .comment { grid-area: cm; margin-left: 8px; width: calc(100% - 8px); }
  .sc { padding: 6px 0; }
  .tab { flex: 1 1 30%; padding: 8px 6px; font-size: 13px; }
  .row.overall { grid-template-columns: 26px 1fr; grid-template-areas: "no name" "bat bat" "sc sc" "cm cm"; }
  .row.overall .battery { grid-area: bat; margin: 0 10px 0 8px; }
  .row.trend { grid-template-columns: 26px 1fr; grid-template-areas: "no name" "lv lv" "cm cm"; }
  .row.trend .levels { grid-area: lv; padding-left: 8px; grid-template-columns: repeat(3, 1fr); }
  .row.test { grid-template-columns: 26px 1fr auto; grid-template-areas: "no name extras" "tc tc tc" "cm cm cm"; }
  .row.test .tcells { grid-area: tc; padding-left: 8px; }
  .test-chip { flex-wrap: wrap; }
  .controls input[type=text] { min-width: 0; flex: 1; }
  .controls .grp.topic { flex: 1 1 100%; }
  .bottom { padding: 8px 12px; }
}
