/*
 * BilMo — zamonaviy, minimal, card-shaklli dizayn tizimi.
 * Ranglar CSS o'zgaruvchilarida. Dark rejim :root[data-theme='dark'] bilan.
 * Shrift: Inter. Ikonlar: FontAwesome. Tailwind (CDN) utilitalar mavjud (preflight o'chirilgan).
 */

:root {
  /* Neytral yuzalar.
     Light rejimda kartalar (oq) fon (kulrang)dan aniq ajralib turishi uchun
     fon biroz to'qroq, chegara va soyalar esa sezilarli qilingan. */
  --bg: #eaeef4;
  --bg-elev: #ffffff;
  --bg-soft: #f1f4f9;
  --bg-softer: #f7f9fc;
  --border: #d9dfe9;
  --border-strong: #c3ccdb;

  /* Matn */
  --text: #0f172a;
  --text-soft: #4b5563;
  --text-mut: #94a3b8;

  /* Brend (indigo) */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-contrast: #ffffff;

  /* Holat ranglari */
  --green: #16a34a;
  --green-soft: #dcfce7;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.08);
  --shadow:
    0 1px 3px rgba(16, 24, 40, 0.08), 0 8px 20px -8px rgba(16, 24, 40, 0.18);
  --shadow-lg: 0 14px 36px -10px rgba(16, 24, 40, 0.28);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

:root[data-theme='dark'] {
  --bg: #0b1120;
  --bg-elev: #151d2e;
  --bg-soft: #1c2740;
  --bg-softer: #121a2b;
  --border: #24304a;
  --border-strong: #33415e;

  --text: #e7ecf3;
  --text-soft: #a3b0c4;
  --text-mut: #6b7a93;

  --accent: #818cf8;
  --accent-hover: #a5b0fb;
  --accent-soft: #1e2542;
  --accent-contrast: #0b1120;

  --green: #4ade80;
  --green-soft: #14301f;
  --red: #f87171;
  --red-soft: #3a1c1c;
  --amber: #fbbf24;
  --amber-soft: #362a12;
  --blue: #60a5fa;
  --blue-soft: #16263f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 16px 40px -10px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font-family: inherit;
  cursor: pointer;
}
img,
table,
pre {
  max-width: 100%;
}
i.fa-solid,
i.fa-regular,
i.fa-brands {
  line-height: 1;
}

/* ============ LOGIN ============ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      1100px 500px at 100% -10%,
      var(--accent-soft),
      transparent 60%
    ),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 38px 34px;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 28px;
}
/* Logotip mavzuga qarab almashadi:
   light rejim -> logo-dark.png (to'q logo, oq fonda ko'rinadi)
   dark  rejim -> logo.png      (oq logo, to'q fonda ko'rinadi)
   Fon rasmi sifatida berilgani uchun faqat KERAKLI fayl yuklanadi. */
.brand-img,
.brand-img-side {
  width: auto;
  max-width: 100%;
  display: block;
  aspect-ratio: 3114 / 712;
  background-image: url('/static/logo-dark.png');
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
.brand-img {
  height: 46px;
}
.brand-img-side {
  height: 30px;
}
:root[data-theme='dark'] .brand-img,
:root[data-theme='dark'] .brand-img-side {
  background-image: url('/static/logo.png');
}
.brand h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 700;
}
.brand p {
  margin: 0;
  font-size: 13px;
  color: var(--text-mut);
}

/* ============ FORM ELEMENTS ============ */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--text-soft);
  margin-bottom: 7px;
}
.input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg-softer);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    background 0.15s;
}
.input::placeholder,
textarea::placeholder {
  color: var(--text-mut);
}
.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.input {
  resize: vertical;
  min-height: 76px;
}
input[type='file'].input {
  padding: 9px 11px;
  font-size: 13px;
}

/* Parolni ko'rish/yashirish tugmasi */
.pw-wrap {
  position: relative;
}
.pw-wrap .input {
  padding-right: 42px;
}
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text-mut);
  display: grid;
  place-items: center;
  font-size: 14px;
  border-radius: 7px;
  cursor: pointer;
}
.pw-toggle:hover {
  color: var(--text);
  background: var(--bg-soft);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 17px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  transition:
    background 0.15s,
    transform 0.06s,
    box-shadow 0.15s,
    border-color 0.15s;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
}
.btn:hover {
  background: var(--accent-hover);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-block {
  width: 100%;
}
.btn-ghost {
  background: var(--bg-elev);
  color: var(--text-soft);
  border-color: var(--border-strong);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--bg-soft);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-sm {
  padding: 7px 12px;
  font-size: 12.5px;
  border-radius: var(--radius-xs);
}
.btn-danger {
  background: var(--red);
  color: #fff;
}
.btn-danger:hover {
  background: #b91c1c;
}
:root[data-theme='dark'] .btn-danger {
  color: #fff;
}

/* ============ ALERT ============ */
.alert {
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.alert.err {
  background: var(--red-soft);
  color: var(--red);
  display: block;
}
.alert.ok {
  background: var(--green-soft);
  color: var(--green);
  display: block;
}

/* ============ APP LAYOUT ============ */
.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
  transition: grid-template-columns 0.2s ease;
}
@media (min-width: 901px) {
  .app.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .app.nav-collapsed .sidebar {
    display: none;
  }
  .app.nav-collapsed .main {
    max-width: 1420px;
    padding-left: clamp(28px, 5vw, 80px);
    padding-right: clamp(28px, 5vw, 80px);
  }
}
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  /* Sidebar o'zi scroll bo'lmaydi — faqat menyu (.nav) scroll bo'ladi,
     logotip va pastdagi profil paneli doim ko'rinib turadi. */
  overflow: hidden;
  transition: transform 0.2s ease;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 18px;
  flex-shrink: 0;
}
.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0; /* flex ichida scroll ishlashi uchun SHART */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-right: 2px;
}
.nav::-webkit-scrollbar {
  width: 6px;
}
.nav::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
}
.nav::-webkit-scrollbar-track {
  background: transparent;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 520;
  color: var(--text-soft);
  transition:
    background 0.12s,
    color 0.12s;
}
.nav a:hover {
  background: var(--bg-soft);
  color: var(--text);
}
.nav a.active {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.nav a.active .ic {
  color: var(--accent-contrast);
}
.nav a .ic {
  width: 20px;
  text-align: center;
  font-size: 15px;
  color: var(--text-mut);
  flex-shrink: 0;
}
.nav a:hover .ic {
  color: var(--text-soft);
}

.side-foot {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 8px;
  flex-shrink: 0; /* menyu uzun bo'lsa ham siqilmaydi */
  background: var(--bg-elev);
}
/* Sidebar avatarida rasm (yuklangan bo'lsa) */
.user-chip .avatar-img {
  width: 36px;
  height: 36px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.12s;
}
.user-chip:hover {
  background: var(--bg-soft);
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.avatar-img {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft);
}
.user-chip .u-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.15;
}
.user-chip .u-role {
  font-size: 11.5px;
  color: var(--text-mut);
  text-transform: capitalize;
}

.main {
  padding: 26px 32px 64px;
  max-width: 1320px;
  width: 100%;
  margin: 0 auto;
  min-width: 0;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar > div:first-child {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.topbar h2 {
  margin: 0;
  font-size: 23px;
  font-weight: 750;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.topbar .sub {
  font-size: 13px;
  color: var(--text-mut);
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.theme-toggle,
.menu-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  color: var(--text-soft);
  display: grid;
  place-items: center;
  font-size: 15px;
  transition:
    background 0.12s,
    color 0.12s;
  flex-shrink: 0;
}
.theme-toggle:hover,
.menu-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(8, 12, 22, 0.5);
  backdrop-filter: blur(2px);
}

/* ============ CARDS & STATS ============ */
.grid {
  display: grid;
  gap: 18px;
}
.stats {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition:
    box-shadow 0.16s,
    transform 0.1s,
    border-color 0.16s;
}
.card-pad {
  padding: 20px 20px;
}
.stat {
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}
.stat .s-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.stat .s-label {
  font-size: 13px;
  color: var(--text-mut);
  font-weight: 550;
  overflow-wrap: anywhere;
}
.stat .s-val {
  font-size: 30px;
  font-weight: 780;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  line-height: 1.15;
}
.stat .s-ic {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.s-ic.green {
  background: var(--green-soft);
  color: var(--green);
}
.s-ic.red {
  background: var(--red-soft);
  color: var(--red);
}
.s-ic.blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.s-ic.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  letter-spacing: -0.01em;
}

/* ============ TABLE (minimalistik) ============ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}
/* Jadval gorizontal siljiganda ham sahifalash paneli ko'rinib tursin */
.table-wrap .pager {
  position: sticky;
  left: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  text-align: left;
  padding: 13px 16px;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-mut);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--bg-softer);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tbody tr:last-child td {
  border-bottom: none;
}
tbody tr {
  transition: background 0.1s;
}
tbody tr:hover {
  background: var(--bg-softer);
}
.muted {
  color: var(--text-mut);
}

/* ============ BADGES & CHIPS ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--bg-soft);
  color: var(--text-soft);
}
.badge.green {
  background: var(--green-soft);
  color: var(--green);
}
.badge.red {
  background: var(--red-soft);
  color: var(--red);
}
.badge.amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.badge.blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.badge.accent {
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
a.chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.row-actions {
  display: flex;
  gap: 7px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ============ TOOLBAR / FORMS ============ */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar .input {
  max-width: 280px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.weekday-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.weekday-pick label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
  transition:
    border-color 0.12s,
    background 0.12s;
}
.weekday-pick label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.weekday-pick input {
  accent-color: var(--accent);
}

/* ============ MODAL ============ */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 44px 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal-back.open {
  display: flex;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  padding: 24px;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}
.modal-head h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-mut);
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover {
  color: var(--text);
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  flex-wrap: wrap;
}

/* Katta modal — web sahifani deyarli to'ldiradi */
.modal.modal-lg {
  max-width: min(1140px, 94vw);
}
.modal-back:has(.modal-lg) {
  padding: 26px 16px;
  align-items: flex-start;
}

/* Fayl webview overlay (rasm/PDF ni modalда ko'rish) */
.fileview-back {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(8, 12, 22, 0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.fileview {
  width: min(1000px, 96vw);
  height: 92vh;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.fileview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.fileview-body {
  flex: 1;
  min-height: 0;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--bg-soft);
}
button.file-pill {
  cursor: pointer;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
  background: #0f172a;
  color: #fff;
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 550;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(12px);
  transition:
    opacity 0.22s,
    transform 0.22s;
  pointer-events: none;
  max-width: 360px;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.err {
  background: var(--red);
  color: #fff;
}
.toast.ok {
  background: var(--green);
  color: #fff;
}

/* ============ MISC ============ */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-mut);
  font-size: 14px;
}
.spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 36px auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.hidden {
  display: none !important;
}
.credbox {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-top: 8px;
  font-size: 13.5px;
}
.credbox b {
  font-family: ui-monospace, 'SF Mono', monospace;
  color: var(--accent);
}
.two-col {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
  align-items: start;
}

/* Avatars / profile / files */
.profile-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.group-card {
  display: flex;
  flex-direction: column;
}
.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 6px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--bg-soft);
  font-size: 12.5px;
  color: var(--text-soft);
  transition:
    border-color 0.12s,
    color 0.12s;
}
.file-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.file-pill span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

/* Quick-link (student overview) */
.quick-link {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}
.quick-link:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Finance cards accent */
.fin-income {
  border-left: 4px solid var(--green);
}
.fin-expense {
  border-left: 4px solid var(--red);
}

/* ============ RATING ============ */
.rank-cell {
  font-size: 18px;
  text-align: center;
}
.rank-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 700;
}
.pts {
  color: var(--accent);
  font-size: 15px;
}
tbody tr.me-row {
  background: var(--accent-soft);
}
tbody tr.me-row:hover {
  background: var(--accent-soft);
}

/* ============ BAR CHART ============ */
.barchart {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 180px;
  padding-top: 24px;
}
.bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}
.bar-val {
  font-size: 10.5px;
  color: var(--text-mut);
  margin-bottom: 6px;
  white-space: nowrap;
  font-weight: 600;
}
.bar-track {
  flex: 1;
  width: 100%;
  max-width: 48px;
  display: flex;
  align-items: flex-end;
}
.bar-fill {
  width: 100%;
  min-height: 3px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(
    180deg,
    var(--accent),
    color-mix(in srgb, var(--accent) 55%, transparent)
  );
  transition: height 0.4s ease;
}
.bar-label {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 8px;
  white-space: nowrap;
  font-weight: 500;
}

/* ============ DAVOMAT: switch / kalendar / jadval ============ */
.att-list {
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.att-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.att-row:last-child {
  border-bottom: none;
}
.att-row:hover {
  background: var(--bg-softer);
}
.att-row .att-name {
  font-size: 13.5px;
}
.att-row .muted {
  font-size: 11.5px;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--red-soft);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s;
  flex-shrink: 0;
  border: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}
.switch:checked {
  background: var(--green);
}
.switch:checked::after {
  transform: translateX(18px);
}

.photo-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.photo-preview {
  margin-top: 8px;
}
.photo-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
video.cam {
  width: 100%;
  max-height: 260px;
  border-radius: 12px;
  background: #000;
  margin-top: 8px;
}

.cal-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}
.cal {
  min-width: 0;
}
.cal-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 12px;
  text-align: center;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-dow {
  font-size: 10.5px;
  color: var(--text-mut);
  text-align: center;
  font-weight: 700;
  padding-bottom: 3px;
  min-width: 0;
}
.cal-cell {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-size: clamp(11px, 3vw, 13px);
  color: var(--text-soft);
  background: var(--bg-soft);
  font-weight: 500;
  min-width: 0;
}
/* Telefon: kalendar bitta ustun, ixchamroq */
@media (max-width: 560px) {
  .cal-wrap {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .cal-grid {
    gap: 3px;
  }
  .cal-cell {
    border-radius: 7px;
  }
}
.cal-cell.empty {
  background: transparent;
}
.cal-cell.present {
  background: var(--green);
  color: #fff;
  font-weight: 700;
}
.cal-cell.absent {
  background: var(--amber);
  color: #fff;
  font-weight: 700;
}
.cal-cell.lesson {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  cursor: help;
}
.cal-cell.today {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.cal-cell.lesson.today {
  outline-color: var(--text);
}
.cal-legend {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  font-size: 12.5px;
  flex-wrap: wrap;
}
.cal-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  display: inline-block;
}
.dot.present {
  background: var(--green);
}
.dot.absent {
  background: var(--amber);
}

.att-table th,
.att-table td {
  text-align: center;
}
.att-table .att-name-col {
  text-align: left;
  white-space: nowrap;
}
.att-head div {
  font-size: 12.5px;
}
.att-photo-link {
  display: inline-block;
  margin-top: 3px;
  font-size: 13px;
  text-decoration: none;
}
.att-cell {
  text-align: center;
}
.att-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 13px;
  cursor: pointer;
  transition:
    transform 0.08s,
    box-shadow 0.1s;
  font-weight: 700;
}
.att-mark:hover {
  transform: scale(1.1);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.att-mark.present {
  background: var(--green-soft);
  color: var(--green);
}
.att-mark.absent {
  background: var(--amber-soft);
  color: var(--amber);
}
.att-mark.none {
  background: var(--bg-soft);
  color: var(--text-mut);
  border: 1px dashed var(--border-strong);
}
.att-mark.none:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============ PAYMENT MODE ============ */
.pay-mode {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-mode label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  transition:
    border-color 0.12s,
    background 0.12s;
}
.pay-mode input {
  accent-color: var(--accent);
}
.pay-mode label:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1120px) and (min-width: 901px) {
  .app:not(.nav-collapsed) {
    grid-template-columns: 220px minmax(0, 1fr);
  }
  .main {
    padding: 24px 24px 56px;
  }
}
@media (max-width: 900px) {
  .app,
  .app.nav-collapsed {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    z-index: 40;
    left: 0;
    top: 0;
    width: 264px;
    max-width: 82vw;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .app.mobile-open .sidebar {
    transform: translateX(0);
  }
  .app.mobile-open .nav-overlay {
    display: block;
  }
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }
  .main {
    padding: 18px 16px 52px;
  }
  .topbar h2 {
    font-size: 20px;
  }
  .modal {
    padding: 20px 17px;
  }
}
@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 15px 13px 46px;
  }
  .modal-back {
    padding: 16px 8px;
  }
  .row-actions {
    flex-wrap: wrap;
  }
  .toolbar {
    gap: 8px;
  }
  /* Inline `style="max-width:..."` ni yengish uchun !important shart —
     aks holda mobil ekranda select'lar tor bo'lib qoladi. */
  .toolbar .input,
  .tt-bar .input {
    max-width: 100% !important;
    flex: 1 1 100%;
  }
  .toolbar .btn,
  .tt-bar .btn {
    flex: 1 1 auto;
  }
  .tt-bar {
    gap: 6px;
  }
  .tt-bar .tt-range {
    flex: 1 1 100%;
    order: -1;
  }
  .section-head {
    gap: 10px;
  }
  .barchart {
    height: 156px;
    gap: 6px;
  }
  .bar-val {
    font-size: 9px;
  }
}
@media (max-width: 380px) {
  .main .grid {
    grid-template-columns: 1fr !important;
  }
  .main {
    padding: 12px 11px 40px;
  }
  .card-pad {
    padding: 15px 14px;
  }
  .stat {
    padding: 16px;
  }
  .stat .s-val {
    font-size: 24px;
  }
  thead th,
  tbody td {
    padding: 10px 11px;
  }
}

/* ============ Dars jadvali / Xona kalendari (Google Calendar uslubi) ============ */
.tt-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.tt-range {
  font-weight: 600;
  font-size: 14.5px;
}
.tt-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
}
.tt-grid {
  display: grid;
  grid-template-columns: 50px repeat(7, minmax(142px, 1fr));
  min-width: 1044px;
}
.tt-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  text-align: center;
  font-size: 12px;
}
.tt-head b {
  display: block;
  font-size: 15px;
}
.tt-head.today {
  color: var(--accent);
}
.tt-head.today b {
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  width: 26px;
  height: 26px;
  line-height: 26px;
  margin: 2px auto 0;
}
.tt-gutter {
  border-right: 1px solid var(--border);
  position: relative;
}
.tt-gutter div {
  height: 42px;
  font-size: 10.5px;
  color: var(--muted);
  text-align: right;
  padding-right: 5px;
  transform: translateY(-6px);
}
.tt-col {
  position: relative;
  border-left: 1px solid var(--border);
}
.tt-col .hr {
  height: 42px;
  border-top: 1px solid var(--border);
}
.tt-col.today {
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}
.tt-ev {
  position: absolute;
  border-radius: 6px;
  padding: 2px 5px;
  font-size: 10.5px;
  line-height: 1.25;
  overflow: hidden;
  cursor: pointer;
  border-left: 3px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg-elev));
  color: var(--text);
  transition: filter 0.12s;
}
.tt-ev:hover {
  filter: brightness(1.06);
}
.tt-ev b {
  display: block;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Juda past blok: vaqt va nom bitta qatorda */
.tt-ev b.one .t {
  opacity: 0.75;
  font-weight: 500;
  margin-right: 2px;
}
.tt-ev .mt {
  opacity: 0.78;
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tt-ev.moved {
  border-left-color: var(--amber, #d97706);
  background: color-mix(in srgb, #d97706 16%, var(--bg-elev));
}
.tt-empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Bir vaqtdagi ko'p dars — yig'ma blok */
.tt-ev.cluster {
  border-left-color: var(--blue, #2563eb);
  background: color-mix(in srgb, #2563eb 15%, var(--bg-elev));
  text-align: left;
}
.tt-ev.cluster b::before {
  content: '\f0c9';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 9px;
  opacity: 0.7;
  margin-right: 4px;
}
