:root {
  --bg: #f1f4f9;
  --side: #1e2a4a;
  --side-2: #16203a;
  --accent: #2f6fed;
  --accent-2: #1d4ed8;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --text: #1f2937;
  --muted: #6b7280;
  --card: #ffffff;
  --line: #e5e7eb;
  --radius: 14px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px; flex: 0 0 260px;
  background: linear-gradient(180deg, var(--side), var(--side-2));
  color: #e5e9f5; padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 6px 8px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 12px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex: 0 0 42px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 17px; color: #fff;
}
.brand-logo-img {
  width: 44px; height: 44px; border-radius: 10px; flex: 0 0 44px;
  background: #fff; object-fit: contain; padding: 3px;
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 11px; color: #9fb0d8; line-height: 1.3; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a {
  color: #cdd6ec; padding: 9px 12px; border-radius: 9px; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.logout { margin-top: 12px; color: #fca5a5; }
.badge {
  background: var(--err); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 1px 7px; font-weight: 700;
}

.content { flex: 1; padding: 22px 26px 40px; min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 18px; gap: 12px; flex-wrap: wrap;
}
.topbar-title { font-size: 21px; font-weight: 700; }
.topbar-user { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.chip {
  background: #e3eaf8; color: var(--accent-2); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
}
.chip.role-admin { background: #fde8e8; color: #b91c1c; }
.chip.role-teacher { background: #e0f2fe; color: #0369a1; }
.chip.role-student { background: #dcfce7; color: #15803d; }
.chip.role-parent { background: #fef3c7; color: #b45309; }
.chip.role-amaliyotchi { background: #ede9fe; color: #6d28d9; }

.muted { color: var(--muted); font-size: 13px; }
#geo-note { margin-left: 10px; }
.checkin-btn {
  background: var(--ok); font-size: 16px; font-weight: 700;
  padding: 12px 22px; border-radius: 12px;
}
.checkin-btn:disabled { background: #9ca3af; cursor: not-allowed; }

.flash {
  padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px;
  border: 1px solid transparent;
}
.flash-ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.flash-wrap { max-width: 420px; margin: 20px auto 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--card); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(16,24,40,.08); border: 1px solid var(--line);
}
.card .num { font-size: 26px; font-weight: 800; margin-top: 4px; }
.card .lbl { color: var(--muted); font-size: 13px; }
.card.accent .num { color: var(--accent); }
.card.ok .num { color: var(--ok); }
.card.warn .num { color: var(--warn); }
.card.err .num { color: var(--err); }

.panel {
  background: var(--card); border-radius: var(--radius); padding: 18px;
  border: 1px solid var(--line); box-shadow: 0 1px 3px rgba(16,24,40,.06);
  margin-bottom: 18px;
}
.panel h2, .panel h3 { margin: 0 0 12px; font-size: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: center; }

.pill { border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.ok { background: #dcfce7; color: #15803d; }
.pill.warn { background: #fef3c7; color: #b45309; }
.pill.err { background: #fee2e2; color: #b91c1c; }
.pill.info { background: #e0e7ff; color: #4338ca; }
.pill.muted { background: #f3f4f6; color: #4b5563; }

/* Jadval katakchasida guruh belgisi va ikkinchi dars ajratgichi */
.pill.guruh { background: #dbeafe; color: #1d4ed8; font-size: 11px; padding: 1px 7px; }
td .guruh-2 { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #cbd5e1; }

/* O'qituvchi cheklovlari to'ri */
.cheklov-grid td.num, .cheklov-grid th.num { width: 120px; }
.cheklov-grid tr.full-day td { background: #fef9e7; }
.cheklov-grid input[type="text"] { width: 100px; padding: 2px 6px; font-size: 12px; }
.cheklov-grid input[type="checkbox"] { width: 18px; height: 18px; vertical-align: middle; }

form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
input, select, textarea {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  font: inherit; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfd3fb; border-color: var(--accent); }
textarea { min-height: 80px; resize: vertical; }
.btn {
  background: var(--accent); color: #fff; border: 0; border-radius: 9px;
  padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost { background: #eef2f9; color: var(--accent-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.danger { background: var(--err); }
form.inline-form { display: inline; }
.about-head { display: flex; gap: 18px; align-items: center; }
.about-logo { width: 96px; height: 96px; object-fit: contain; background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.structure-list { margin: 6px 0 0; padding-left: 20px; line-height: 1.9; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; }

/* O'quvchi tanlagich (picker) — qidiruv + sinf filtri + natijalar ro'yxati */
.picker { position: relative; }
.picker-native.is-hidden { display: none; }
.picker-bar { display: flex; gap: 8px; }
.picker-bar .picker-search { flex: 1; }
.picker-bar .picker-class { width: 150px; }
.picker-list {
  position: absolute; z-index: 40; top: 100%; left: 0; right: 0; margin-top: 4px;
  max-height: 300px; overflow: auto; background: #fff; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 10px 26px rgba(16,24,40,.16);
}
.picker-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  border-bottom: 1px solid #f1f5f9; padding: 7px 10px; font: inherit; cursor: pointer;
}
.picker-item:last-child { border-bottom: 0; }
.picker-item:hover, .picker-item.active { background: #eef2f9; }
.picker-item .sub { display: block; color: var(--muted); font-size: 12px; }
.picker-empty { padding: 9px 10px; color: var(--muted); font-size: 13px; }
.picker-meta { font-size: 12px; margin-top: 6px; }
.picker-meta.warn { color: #b45309; font-weight: 600; }

/* Chiqish zanjiri: so'rov → rahbar → QR-talon → qabul */
.chain { display: flex; gap: 4px; flex-wrap: wrap; }
.chain-step {
  font-size: 11px; padding: 2px 7px; border-radius: 999px; white-space: nowrap;
  background: #f3f4f6; color: #9ca3af; border: 1px solid transparent;
}
.chain-step.on { background: #dcfce7; color: #15803d; }
.chain-step.cur { background: #2563eb; color: #fff; font-weight: 700; }

.att-radio { display: flex; gap: 6px; }
.att-radio label {
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px;
  font-size: 12px; cursor: pointer; background: #fff;
}
.att-radio input { display: none; }
.att-radio input:checked + label.l-bor { background: #dcfce7; border-color: #86efac; color: #15803d; }
.att-radio input:checked + label.l-yoq { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
.att-radio input:checked + label.l-kech { background: #fef3c7; border-color: #fde68a; color: #b45309; }
.att-radio input:checked + label.l-sababli { background: #e0e7ff; border-color: #c7d2fe; color: #4338ca; }

.grade-cell { display: flex; gap: 4px; flex-wrap: wrap; }
.g { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.g.g5 { background: #dcfce7; color: #15803d; }
.g.g4 { background: #e0f2fe; color: #0369a1; }
.g.g3 { background: #fef3c7; color: #b45309; }
.g.g2, .g.g1 { background: #fee2e2; color: #b91c1c; }

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2a4a, #2f6fed 60%, #7c3aed);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 18px; padding: 34px 32px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 24px; text-align: center; }
.login-logo { width: 88px; height: 88px; object-fit: contain; display: block; margin: 0 auto 10px; }
.login-card p.sub { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.demo-logins { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.demo-logins code { background: #f3f4f6; padding: 1px 6px; border-radius: 6px; }

.rec-list { margin: 0; padding-left: 18px; line-height: 1.7; }
.rec-list li { margin-bottom: 6px; }

.news-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }
.news-item .date { color: var(--muted); font-size: 12px; }

/* Talon chop etish */
.talon-sheet { max-width: 760px; margin: 0 auto; background: #fff; padding: 46px 54px; border: 1px solid var(--line); border-radius: 6px; }
.talon-sheet .t-head { text-align: center; border-bottom: 2px solid #111; padding-bottom: 12px; margin-bottom: 22px; }
/* O'zbekiston Gerbi — bosma varaqalar tepasida, o'rtada */
.talon-sheet .gerb { text-align: center; margin-bottom: 8px; }
.talon-sheet .gerb img { width: 76px; height: auto; }
.talon-sheet .head { font-size: 12.5px; line-height: 1.5; text-transform: uppercase; }
.talon-sheet h1 { font-size: 20px; margin: 6px 0; }
.talon-sheet table td { border: 1px solid #999; padding: 7px 10px; }
.talon-sheet .sign { display: flex; justify-content: space-between; margin-top: 44px; font-size: 14px; }
/* Imzo qatori: chapda direktor, o'rtada QR, o'ngda ota-ona (yirik harflar bilan) */
.talon-sheet .sig { display: flex; justify-content: space-between; align-items: flex-start;
  gap: 22px; margin-top: 42px; font-size: 15.5px; }
.talon-sheet .sig .who { flex: 1; }
.talon-sheet .sig .who b { display: block; margin-top: 30px; font-size: 16.5px; }
.talon-sheet .sig .qr { flex: 0 0 auto; text-align: center; }
.talon-sheet .sig .qr img { width: 132px; height: 132px; border: 1px solid #ccc; padding: 3px; }
.talon-sheet .sig .qr .hint { font-size: 11px; color: #5a6b80; margin-top: 5px; line-height: 1.4; }
.no-print { margin-bottom: 14px; text-align: center; }

/* Individual rivojlanish kartasi — bosma varaq */
.print-sheet table td, .print-sheet table th { border: 1px solid #9aa4b2; }
.print-sheet tr { page-break-inside: avoid; }
@media print {
  .print-sheet { border: 0; box-shadow: none; padding: 0; }
}
@media print {
  .sidebar, .topbar, .no-print, .flash { display: none !important; }
  .content { padding: 0; }
  .talon-sheet { border: 0; border-radius: 0; padding: 0; }
  body { background: #fff; }
}

/* ---------- Xarita (Leaflet) ---------- */
.map-box { position: relative; height: 420px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--line); background: #dfe6ef; }
.map-box.short { height: 320px; }
.map-offline { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 900;
  background: rgba(30,42,74,.9); color: #fff; font-size: 12px; padding: 8px 10px;
  border-radius: 8px; text-align: center; }
.map-pin { background: none; border: 0; }
.map-pin span { display: block; width: 20px; height: 20px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); background: var(--accent); border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(16,24,40,.4); }
.map-pin-school span { background: #1d4ed8; width: 22px; height: 22px; }
.map-hint { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 12.5px; }
.map-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  margin-right: 5px; vertical-align: -1px; }

/* ---------- Yuz (selfie) tasdiqi ---------- */
.face-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: #eef2f7; display: block; }
.face-thumb.big { width: 104px; height: 104px; }

/* ---------- Haftalik dars jadvali varaqasi ---------- */
table.jadval-haftalik { width: 100%; table-layout: fixed; font-size: 11.5px; }
table.jadval-haftalik th { background: #eef2f7; font-size: 11.5px; padding: 4px 5px; }
table.jadval-haftalik td { vertical-align: top; padding: 4px 5px;
  border: 1px solid var(--line); word-break: break-word; }
table.jadval-haftalik td.jh-name { width: 118px; font-weight: 600; background: #fbfcfe; }
table.jadval-haftalik .jh-meta { font-weight: 400; font-size: 10.5px; }
.jh-lesson { margin-bottom: 4px; padding-bottom: 3px;
  border-bottom: 1px dotted #dfe6ef; }
.jh-lesson:last-child { border-bottom: 0; }
.jh-lesson b { display: inline-block; min-width: 13px; }
.jh-sub { color: var(--muted); font-size: 10.5px; }
.jh-kel { color: #b26a00; }
@media print {
  @page { size: A4 landscape; margin: 9mm; }
  table.jadval-haftalik { font-size: 8.5px; }
  table.jadval-haftalik td, table.jadval-haftalik th { padding: 2px 3px; }
  .panel { box-shadow: none; border: 0; padding: 0; page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
