:root {
  --bg: #f1f5f9; --card: #fff; --ink: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --primary: #2563eb; --primary-d: #1d4ed8;
  --green: #16a34a; --red: #dc2626; --amber: #d97706;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }   /* CSS display: grid/flex hidden'ни босиб кетмаслиги учун */
.err { color: var(--red); margin-top: 8px; font-size: 14px; }
.right { text-align: right; }
.center { text-align: center; }

/* Логин */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: linear-gradient(135deg, #1e293b, #0f172a); }
.login-card { background: var(--card); padding: 32px; border-radius: 16px; width: 100%;
  max-width: 360px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card label { display: block; margin: 16px 0 0; font-size: 13px; color: var(--muted); }
.login-card input { width: 100%; margin-top: 6px; padding: 11px 12px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; }
.login-card button { width: 100%; margin-top: 20px; }

/* Лейаут: чап сайдбар + контент */
#app { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar { width: 216px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 17px; padding: 2px 10px 18px; white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button { text-align: left; background: none; border: none; padding: 10px 12px; border-radius: 9px;
  cursor: pointer; color: var(--muted); font-size: 14px; white-space: nowrap; width: 100%; }
.nav button:hover { background: #f1f5f9; color: var(--ink); }
.nav button.active { background: #eff6ff; color: var(--primary); font-weight: 600; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.side-foot #userName { padding: 0 10px; }
.side-foot button { text-align: left; }

.view { flex: 1; min-width: 0; max-width: 1100px; padding: 26px 30px 60px; }

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: auto; height: auto; flex-direction: row; align-items: center; gap: 8px;
    position: sticky; top: 0; z-index: 10; padding: 8px 12px; overflow-x: auto;
    border-right: none; border-bottom: 1px solid var(--line); }
  .brand { padding: 4px 6px; font-size: 16px; }
  .nav { flex-direction: row; flex: 1; }
  .side-foot { margin-top: 0; padding-top: 0; border-top: none; flex-direction: row;
    align-items: center; gap: 8px; }
  .side-foot #userName { display: none; }
  .view { padding: 18px 16px 60px; }
}

/* Кнопкалар */
.btn { padding: 9px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--card);
  cursor: pointer; font-size: 14px; color: var(--ink); }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 9px; font-size: 13px; }
.btn-danger { color: var(--red); }

/* Карточкалар / гридлар */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 13px; }
.card-ico { font-size: 20px; width: 44px; height: 44px; flex-shrink: 0; border-radius: 11px;
  display: grid; place-items: center; background: #f1f5f9; }
.card .lbl { color: var(--muted); font-size: 13px; line-height: 1.3; }
.card .val { font-size: 21px; font-weight: 700; margin-top: 3px; }
.val.green { color: var(--green); } .val.red { color: var(--red); } .val.amber { color: var(--amber); }
.val.accent { color: var(--primary); }

/* Бошпанел сарлавҳа ва бўлимлар */
.dash-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.dash-head h2 { margin: 0; }
.dash-head .date { color: var(--muted); font-size: 14px; }
.dash-actions { margin-left: auto; display: flex; gap: 8px; }
.dash-sec { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  font-weight: 700; margin: 22px 0 10px; }

.section { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-top: 20px; overflow: hidden; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line); }
.section-head h2 { margin: 0; font-size: 16px; }
.section-body { padding: 4px 0; }
.pad { padding: 16px; }

/* Жадвал */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 16px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f8fafc; }
tbody tr:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Чиплар */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip-green { background: #dcfce7; color: #166534; }
.chip-amber { background: #fef3c7; color: #92400e; }
.chip-red { background: #fee2e2; color: #991b1b; }
.chip-gray { background: #f1f5f9; color: #475569; }

/* Форма / модал */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center;
  z-index: 50; padding: 16px; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh;
  overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px;
  border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 9px; font-size: 14px; font-family: inherit; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink);
  color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 14px; z-index: 100; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* Балл бейджи ва прогресс */
.score { display: inline-flex; align-items: center; justify-content: center; min-width: 46px;
  padding: 3px 9px; border-radius: 999px; font-weight: 700; font-size: 13px; }
.score.good { background: #dcfce7; color: #166534; }
.score.mid { background: #fef3c7; color: #92400e; }
.score.bad { background: #fee2e2; color: #991b1b; }
.bar { height: 8px; border-radius: 999px; background: #eef2f7; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; border-radius: 999px; }
.bar .b-good { background: var(--green); } .bar .b-mid { background: var(--amber); } .bar .b-bad { background: var(--red); }
.starrow { color: #f59e0b; letter-spacing: 1px; }
.linklike { color: var(--primary); cursor: pointer; }
.linklike:hover { text-decoration: underline; }
.period-pick { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.period-pick input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; font-size: 14px; }

/* Рейтинг: ғолиб баннери + подиум */
.winner { margin-top: 14px; display: flex; align-items: center; gap: 18px; padding: 20px 22px;
  border-radius: 14px; border: 1px solid #fde68a; background: linear-gradient(135deg, #fffbeb, #fef3c7); }
.winner .trophy { font-size: 42px; line-height: 1; }
.winner .wname { font-size: 22px; font-weight: 700; margin: 2px 0; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.pod { text-align: center; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.pod .medal { font-size: 30px; }
.pod .pname { font-weight: 600; margin-top: 6px; }
.pod .pscore { font-size: 22px; font-weight: 700; margin-top: 2px; }
.rank-num { display: inline-block; width: 26px; font-weight: 700; color: var(--muted); }
@media (max-width: 640px) { .podium { grid-template-columns: 1fr; } }
@media (max-width: 640px) {
  .row2 { grid-template-columns: 1fr; }
  th, td { padding: 9px 10px; }
}
