:root {
  /* Фирменные цвета IT-Top + глубокий фиолетовый градиент */
  --brand: #ec1b2e;             /* IT-Top красный */
  --brand-2: #ff6a3d;           /* оранжевый акцент */
  --purple-glow: rgba(168, 85, 247, 0.4);
  --purple-brand: #9333ea;
  --purple-light: #c084fc;

  --bg: #0d061f;                /* глубокий космический фиолетовый */
  --panel: rgba(22, 11, 46, 0.88);
  --card: rgba(32, 17, 66, 0.72);
  --card-2: rgba(45, 23, 90, 0.65);
  --card-hover: rgba(58, 29, 114, 0.8);
  --stroke: rgba(192, 132, 252, 0.16);
  --stroke-2: rgba(192, 132, 252, 0.32);
  --txt: #f1f3f9;
  --muted: #a39bb8;
  
  --good: #10b981;              /* 5 — изумрудный */
  --info: #3b82f6;              /* 4 — лазурный */
  --warn: #f59e0b;              /* 3 — янтарный */
  --bad: #ef4444;               /* 2/1 — коралловый */

  --radius: 16px;
  --shadow: 0 16px 44px rgba(10, 3, 26, 0.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--txt);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: "JetBrains Mono", monospace; }

/* Фон: шикарный глубокий фиолетовый градиент со свечением */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1100px 750px at 85% -10%, rgba(168, 85, 247, 0.30), transparent 65%),
    radial-gradient(900px 650px at -10% 105%, rgba(217, 70, 239, 0.24), transparent 60%),
    radial-gradient(800px 600px at 50% 45%, rgba(99, 102, 241, 0.18), transparent 70%),
    linear-gradient(145deg, #090317 0%, #15082e 35%, #230b4b 70%, #0d061f 100%);
}

.glass {
  background: var(--card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

/* ===== Логотип IT-Top ===== */
.logo-mark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.logo-mark .box {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  padding: 4px 8px;
  border-radius: 9px;
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 6px 18px rgba(236,27,46,0.45);
}
.logo-mark .word { font-size: 20px; }
.logo-mark .word b { color: var(--brand); }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%;
  max-width: 390px;
  border-radius: 22px;
  padding: 34px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}
.brand { display: flex; align-items: center; gap: 15px; margin-bottom: 8px; }
.brand .brand-logo {
  width: 92px;
  height: auto;
  flex: 0 0 auto;
  filter: drop-shadow(0 8px 22px rgba(192, 132, 252, 0.45));
}
.brand .brand-text {
  padding-left: 15px;
  border-left: 1px solid var(--stroke-2);
}
.brand h1 { margin: 0; font-size: 25px; letter-spacing: -0.5px; }
.brand h1 b { color: var(--brand); }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="text"], input[type="password"], input[type="search"], textarea, input:not([type]) {
  background: rgba(18, 7, 38, 0.65);
  border: 1px solid var(--stroke-2);
  color: var(--txt);
  padding: 12px 14px;
  border-radius: 11px;
  font-size: 14px;
  outline: none;
  transition: border 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
input:focus, textarea:focus {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.25);
}
.remember { flex-direction: row; align-items: center; gap: 8px; }
.remember input { width: 16px; height: 16px; accent-color: var(--brand); }

.btn-primary {
  margin-top: 6px;
  border: none;
  cursor: pointer;
  color: #fff;
  font-weight: 800;
  font-size: 14.5px;
  padding: 12px 18px;
  border-radius: 11px;
  background: linear-gradient(135deg, #a855f7, #ec1b2e);
  box-shadow: 0 8px 24px rgba(168, 85, 247, 0.4);
  transition: transform 0.15s, filter 0.2s, box-shadow 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
  box-shadow: 0 12px 28px rgba(168, 85, 247, 0.5);
}
.btn-primary:disabled { opacity: 0.6; cursor: wait; }

.btn-sec {
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-sec:hover {
  background: var(--card-hover);
  border-color: var(--stroke-2);
}

.err { color: var(--bad); font-size: 13px; min-height: 16px; margin: 0; text-align: center; }

/* ===== App layout ===== */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 20px;
  padding: 20px 26px;
  min-height: 100vh;
  max-width: 1900px;
  margin: 0 auto;
}
@media (min-width: 1700px) {
  .app { gap: 24px; padding: 24px 34px; }
}
.sidebar {
  border-radius: var(--radius);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: sticky;
  top: 18px;
  height: calc(100vh - 36px);
  background: var(--panel);
}
.brand.small { gap: 10px; margin: 4px 6px 12px; }
#nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
#nav button, .logout {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 11px 14px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
}
#nav button:hover {
  color: #fff;
  background: rgba(168, 85, 247, 0.12);
}
#nav button.active {
  color: #fff;
  background: linear-gradient(135deg, #9333ea, #c026d3);
  box-shadow: 0 8px 22px rgba(147, 51, 234, 0.4);
}
.logout { margin-top: auto; color: var(--bad); }
.logout:hover { background: rgba(239,68,68,0.15); }

.content { min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.topbar h2 { margin: 0; font-size: 26px; letter-spacing: -0.5px; }
.topbar p { margin: 3px 0 0; font-size: 13.5px; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px 8px 8px;
  border-radius: 100px;
  background: var(--card);
  border: 1px solid var(--stroke);
}
.user-chip img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple-light);
}
.user-chip .u-name { font-weight: 700; font-size: 14px; }
.user-chip .u-grp { font-size: 12px; color: var(--purple-light); }

/* ===== Cards & grid ===== */
.view { display: flex; flex-direction: column; gap: 18px; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.grid { display: grid; gap: 16px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.card { border-radius: var(--radius); padding: 20px; }
.card h3 { margin: 0 0 6px; font-size: 16px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.stat { position: relative; overflow: hidden; }
.stat .ic {
  font-size: 19px;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
}
.stat .val { font-size: 30px; font-weight: 800; letter-spacing: -1px; line-height: 1; }
.stat .lbl { color: var(--muted); font-size: 13px; margin-top: 6px; }

.levelbar {
  height: 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  margin-top: 12px;
}
.levelbar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #9333ea, #ec1b2e);
  border-radius: 6px;
}

.chart svg { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }

/* ===== Rows & lists ===== */
.rowlist { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 6px;
  border-bottom: 1px solid var(--stroke);
}
.row:last-child { border-bottom: none; }
.row .lead {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13.5px;
  flex: none;
  background: var(--card-2);
  color: var(--muted);
}
.row .main { flex: 1; min-width: 0; }
.row .t1 { font-weight: 700; font-size: 14.5px; }
.row .t2 { color: var(--muted); font-size: 13px; margin-top: 3px; }
.row .side { text-align: right; font-size: 13px; color: var(--muted); flex: none; }

/* Оценки 5, 4, 3, 2 */
.mark {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  font-weight: 800;
  display: inline-grid;
  place-items: center;
  font-size: 13.5px;
}
.m5 { background: rgba(16, 185, 129, 0.22); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.4); }
.m4 { background: rgba(59, 130, 246, 0.22); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.4); }
.m3 { background: rgba(245, 158, 11, 0.22); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.4); }
.m2 { background: rgba(239, 68, 68, 0.22); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.4); }

.pill { font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 100px; white-space: nowrap; }
.pill.on { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.35); }
.pill.off { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35); }
.pill.wait { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }

/* Статусы в toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .grow { flex: 1; min-width: 200px; }
.toolbar input[type="search"] { width: 100%; padding: 10px 14px; border-radius: 11px; font-size: 14px; }

.mini-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.chipstat {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 11px;
  padding: 8px 14px;
  font-size: 13px;
}
.chipstat b { font-size: 15px; }
.chipstat .cs-purple { color: var(--purple-light); }

/* ===== ГЕЙМИФИКАЦИЯ ===== */
.user-chip .wallet { display: flex; gap: 8px; margin-right: 6px; }
.cur {
  font-size: 12.5px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 100px;
  font-family: "JetBrains Mono", monospace;
  white-space: nowrap;
}
.cur-lvl { background: rgba(147, 51, 234, 0.25); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.35); }
.cur-gold { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.35); }
.cur-gem { background: rgba(6, 182, 212, 0.2); color: #67e8f9; border: 1px solid rgba(6, 182, 212, 0.35); }

/* ===== ЛЕГЕНДА ОЦЕНОК (ПОКАЗЫВАЕТСЯ ПЕРВОЙ) ===== */
.legend-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: linear-gradient(145deg, rgba(38, 18, 78, 0.75), rgba(24, 11, 52, 0.85));
}
.leg-title { font-size: 13px; font-weight: 800; margin-bottom: 10px; letter-spacing: 0.3px; color: var(--purple-light); }
.leg-row { display: flex; flex-wrap: wrap; gap: 8px; }
.leg-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  color: var(--txt);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.leg-chip:hover { border-color: var(--purple-light); transform: translateY(-1px); }
.leg-chip.sel {
  border-color: var(--purple-light);
  background: rgba(147, 51, 234, 0.28);
  box-shadow: 0 0 0 2px rgba(168, 85, 247, 0.35);
}
.leg-badge {
  min-width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  font-weight: 800;
  font-size: 13px;
}
.leg-cnt {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255,255,255,0.08);
  padding: 1px 7px;
  border-radius: 6px;
}
.leg-chip.work b { color: var(--purple-light); }
.leg-chip.hw-tag { border-color: rgba(168, 85, 247, 0.4); background: rgba(147, 51, 234, 0.18); }
.leg-chip.hw-tag b { color: #f472b6; }
.leg-active { font-size: 13.5px; color: var(--muted); min-height: 4px; }
.leg-reset {
  background: transparent;
  border: none;
  color: var(--purple-light);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  margin-left: 8px;
  text-decoration: underline;
}

/* ===== СЕТКА КАРТОЧЕК ОЦЕНОК (КАРТОЧКИ ТАБЛИЦЕЙ) ===== */
.cards-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.mark-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
  position: relative;
  overflow: hidden;
}
.mark-card:hover {
  transform: translateY(-2px);
  border-color: var(--stroke-2);
  box-shadow: 0 12px 30px rgba(10, 4, 30, 0.5);
}
.mark-card.has-hw {
  border-color: rgba(168, 85, 247, 0.35);
  background: linear-gradient(150deg, rgba(42, 20, 86, 0.8), rgba(26, 13, 56, 0.75));
}
.mc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding-bottom: 10px;
}
.mc-date { display: flex; align-items: baseline; gap: 6px; }
.mc-wd { font-weight: 800; font-size: 13.5px; color: var(--purple-light); }
.mc-num { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--muted); }
.mc-lesson {
  font-size: 11px;
  font-weight: 700;
  background: rgba(255,255,255,0.07);
  padding: 2px 7px;
  border-radius: 6px;
}
.mc-body { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.mc-subj { font-weight: 700; font-size: 15px; line-height: 1.35; }
.mc-theme { font-size: 13.5px; color: var(--txt); opacity: 0.85; line-height: 1.4; }
.mc-teacher { font-size: 12.5px; color: var(--muted); margin-top: 4px; }

/* Выделенный блок ДЗ внутри карточки */
.hw-highlight-box {
  background: rgba(147, 51, 234, 0.16);
  border: 1px solid rgba(192, 132, 252, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 2px;
}
.hw-highlight-title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #f5d0fe;
}
.mc-marks-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.gmark {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border-radius: 9px;
  font-weight: 800;
  font-size: 14.5px;
}
.gmark .gm-t {
  font-size: 10.5px;
  font-weight: 700;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.gmark.hw-mark {
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.3);
}

.att-badge { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 100px; white-space: nowrap; }
.att-badge.on { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.att-badge.off { background: rgba(239, 68, 68, 0.2); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }

/* ===== ДОМАШКА: КАРТОЧКИ И СДАЧА ===== */
.hw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
}
.hw-card {
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  transition: transform 0.18s, box-shadow 0.18s;
}
.hw-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(12, 4, 32, 0.55);
}
.hw-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.hw-spec { font-size: 13px; font-weight: 700; color: var(--purple-light); }
.hw-theme { font-size: 16px; font-weight: 800; line-height: 1.35; margin-top: 4px; }
.hw-teach { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.hw-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  padding-top: 10px;
  border-top: 1px solid var(--stroke);
}
.hw-due { display: flex; align-items: center; gap: 6px; }
.hw-due.overdue { color: var(--bad); font-weight: 700; }
.hw-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
}
.btn-submit-hw {
  background: linear-gradient(135deg, #a855f7, #9333ea);
  color: #fff;
  border: none;
  font: inherit;
  font-weight: 700;
  font-size: 13.5px;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: 0 6px 18px rgba(147, 51, 234, 0.35);
}
.btn-submit-hw:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}
.hw-file {
  font-size: 12.5px;
  color: var(--purple-light);
  text-decoration: none;
  font-weight: 700;
  padding: 8px 12px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
}
.hw-file:hover {
  background: var(--card-hover);
  border-color: var(--purple-light);
}

.submission-box {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-title { font-size: 12.5px; font-weight: 800; color: #34d399; display: flex; align-items: center; gap: 6px; }
.sb-file { font-size: 13px; word-break: break-all; }
.sb-comment { font-size: 12.5px; color: var(--txt); opacity: 0.9; font-style: italic; }

/* ===== МОДАЛКА СДАЧИ ДЗ ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(8, 3, 20, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal-card {
  width: 100%;
  max-width: 520px;
  border-radius: 20px;
  padding: 26px;
  background: linear-gradient(155deg, rgba(38, 18, 76, 0.95), rgba(20, 9, 44, 0.95));
  border: 1px solid var(--stroke-2);
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  animation: pop 0.2s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}
.modal-header h3 { margin: 0; font-size: 19px; letter-spacing: -0.3px; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}
.modal-close:hover { color: #fff; background: rgba(255,255,255,0.08); }
.modal-body { display: flex; flex-direction: column; gap: 16px; }

.hw-dropzone {
  border: 2px dashed rgba(168, 85, 247, 0.4);
  background: rgba(147, 51, 234, 0.08);
  border-radius: 14px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
}
.hw-dropzone:hover, .hw-dropzone.dragover {
  border-color: var(--purple-light);
  background: rgba(147, 51, 234, 0.16);
}
.dz-icon { font-size: 36px; display: block; margin-bottom: 8px; }
.dz-prompt { margin: 0; font-size: 14.5px; }
.dz-hint { font-size: 12px; color: var(--muted); margin-top: 4px; display: block; }
.dz-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card-2);
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
}
.dz-file-name { font-weight: 700; font-size: 14px; word-break: break-all; }
.btn-remove-file {
  background: transparent;
  border: none;
  color: var(--bad);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
}

/* ===== СЕГМЕНТЫ / ПЕРЕКЛЮЧАТЕЛИ ===== */
.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: var(--card-2);
  border: 1px solid var(--stroke);
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 16px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.seg button:hover { color: #fff; }
.seg button.active {
  background: linear-gradient(135deg, #9333ea, #c026d3);
  color: #fff;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.35);
}

/* Расписание */
.day {
  border-radius: 16px;
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--stroke);
}
.day.today {
  border-color: var(--purple-light);
  box-shadow: 0 0 0 1px var(--purple-light) inset, 0 8px 24px rgba(147, 51, 234, 0.25);
}
.day h4 { margin: 0 0 12px; font-size: 14px; color: var(--purple-light); }
.lesson { display: flex; gap: 12px; padding: 9px 0; border-top: 1px dashed var(--stroke); }
.lesson:first-of-type { border-top: none; }
.lesson .time {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--purple-light);
  flex: none;
  width: 46px;
}
.lesson .info .s { font-size: 13.5px; font-weight: 700; }
.lesson .info .m { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Рейтинг */
.leaders-podium {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  align-items: end;
  margin-bottom: 12px;
}
.pod {
  border-radius: 16px;
  padding: 18px 12px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--stroke);
}
.pod img {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--purple-light);
  margin-bottom: 8px;
}
.pod .rk { font-size: 22px; }
.pod .nm { font-size: 13px; font-weight: 700; line-height: 1.3; }
.pod .pt {
  font-family: "JetBrains Mono", monospace;
  color: #fbbf24;
  font-size: 14px;
  font-weight: 800;
  margin-top: 6px;
}
.pod.p1 {
  transform: translateY(-8px);
  border-color: rgba(245, 158, 11, 0.5);
  box-shadow: 0 12px 34px rgba(245, 158, 11, 0.2);
}
.me-row {
  background: linear-gradient(90deg, rgba(147, 51, 234, 0.22), transparent);
  border-radius: 11px;
}

.loading, .empty { text-align: center; color: var(--muted); padding: 42px; font-size: 14.5px; }
.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid var(--stroke-2);
  border-top-color: var(--purple-light);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Предметы */
.subj-list { display: flex; flex-direction: column; }
.subj-row {
  display: grid;
  grid-template-columns: 1fr 70px 70px 150px 90px;
  gap: 14px;
  align-items: center;
  padding: 14px 8px;
  border-bottom: 1px solid var(--stroke);
}
.subj-row:hover { background: rgba(255,255,255,0.03); }
.sr-name { font-weight: 700; font-size: 14.5px; }
.sr-stat { font-size: 13.5px; }
.sr-att { display: flex; align-items: center; gap: 9px; }
.bar {
  height: 7px;
  border-radius: 4px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
  min-width: 70px;
}
.bar i {
  display: block;
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #9333ea, #ec1b2e);
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  #nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  .logout { margin: 0; }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-3, .g-2 { grid-template-columns: 1fr; }
  .leaders-podium { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .user-chip .wallet { display: none; }
  .cards-matrix { grid-template-columns: 1fr; }
  .subj-row { grid-template-columns: 1fr auto; row-gap: 8px; }
  .sr-att { grid-column: 1 / -1; }
}

/* ===== Расписание: день / неделя / месяц ===== */
.sch-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.sch-nav { display: flex; gap: 6px; }
.nav-btn { border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--txt);
  font: inherit; font-weight: 700; font-size: 14px; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  transition: all .15s; }
.nav-btn:hover { border-color: var(--brand); color: var(--brand); }
.sch-title { font-weight: 800; font-size: 16px; margin-left: auto; }
.sch-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; align-items: start; }
.sch-month { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; align-items: start; }
.sch-day-wrap { max-width: 620px; }
.day-big .lesson { padding: 10px 0; }
.day-big h4 { font-size: 15px; }
@media (max-width: 1200px) { .sch-week { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 720px) { .sch-week { grid-template-columns: 1fr; } }

/* ===== Домашки: комментарии, скриншоты, сдача ===== */
.hw-note { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke); font-size: 13px; line-height: 1.45; }
.hw-note .nt { font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--muted); display: block; margin-bottom: 4px; }
.hw-note.teacher { border-color: rgba(147,51,234,0.3); background: rgba(147,51,234,0.08); }
.hw-cover { margin: 10px 0; }
.hw-cover img { width: 100%; max-height: 200px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--stroke); cursor: zoom-in; display: block; }
.hw-cover .cap { font-size: 11px; color: var(--muted); margin-top: 4px; }

.seg { flex-wrap: wrap; }
.hw-card.hw-overdue { border-color: rgba(239,68,68,0.45); box-shadow: 0 0 0 1px rgba(239,68,68,0.25) inset, var(--shadow); }

/* ===== Счётчики на вкладках домашки ===== */
.seg button .cnt { font-style: normal; font-size: 11px; font-weight: 800; margin-left: 7px;
  padding: 1px 6px; border-radius: 999px; background: rgba(255,255,255,0.08); color: var(--muted);
  display: none; }
.seg button .cnt.on { display: inline-block; }
.seg button.active .cnt.on { background: rgba(255,255,255,0.22); color: #fff; }

/* ===== Новости: раскрытие текста ===== */
.news-row { cursor: pointer; }
.news-row:hover { background: rgba(255,255,255,0.04); }
.news-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.news-chev { color: var(--muted); font-size: 13px; }
.news-text { margin-top: 10px; font-size: 13.5px; line-height: 1.55; }
.news-html img { max-width: 100%; height: auto; border-radius: 10px; }
.news-html a { color: var(--brand); }
.news-html p { margin: 0 0 8px; }

/* ===== Профиль ===== */
.profile-head { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile-photo { width: 92px; height: 92px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--stroke-2); flex: none; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.ach { text-align: center; padding: 10px 8px; border-radius: 12px; background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke); }
.ach img { width: 52px; height: 52px; object-fit: contain; margin-bottom: 6px; }
.ach-ph { font-size: 34px; line-height: 1; margin-bottom: 6px; }
.ach-name { font-size: 12.5px; font-weight: 700; line-height: 1.3; }
.ach-desc { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.35; }
@media (max-width: 720px) {
  .profile-head { flex-direction: column; align-items: flex-start; }
  .profile-photo { width: 72px; height: 72px; }
}

/* ===== ЧАТ: общие элементы ленты ===== */
.chat-day { text-align: center; font-size: 11px; color: var(--muted); margin: 12px 0 8px;
  text-transform: lowercase; }
/* Сообщение: аватарка слева, тело справа; свои — зеркально */
.msg { margin-bottom: 10px; display: flex; align-items: flex-end; gap: 9px; }
.msg.own { flex-direction: row-reverse; }
.msg.grouped { margin-bottom: 4px; }
.msg-ava, .msg-ava-sp { width: 34px; height: 34px; flex: none; }
.msg-ava { border-radius: 50%; object-fit: cover; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 800; color: #fff; letter-spacing: .3px;
  border: 1px solid var(--stroke-2); }
.msg-ava.ava-sys { background: var(--card-2); color: var(--purple-light); font-size: 15px; }
.msg-body { min-width: 0; max-width: 78%; display: flex; flex-direction: column; align-items: flex-start; }
.msg.own .msg-body { align-items: flex-end; }
.msg-author { font-size: 11.5px; font-weight: 700; color: var(--purple-light); margin-bottom: 3px; }
.msg-bubble { padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px;
  background: var(--card-2); border: 1px solid var(--stroke); font-size: 13.5px; line-height: 1.45;
  word-break: break-word; display: flex; align-items: flex-end; gap: 8px; }
.msg.own .msg-bubble { border-radius: 14px 14px 4px 14px;
  background: linear-gradient(135deg, rgba(147,51,234,0.35), rgba(236,27,46,0.25));
  border-color: var(--stroke-2); }
.msg.sys .msg-bubble { background: rgba(255,255,255,0.05); font-style: italic; color: var(--muted); }
.msg-time { font-size: 10px; color: var(--muted); flex: none; }
.chat-empty { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 12px; line-height: 1.6; }

/* ===== ЧАТ: полноэкранный раздел ===== */
.chat-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.chat-side h3 { margin-top: 0; }
.chat-chans { display: flex; flex-direction: column; gap: 6px; }
.chat-chan { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-align: left;
  padding: 9px 11px; border-radius: 11px; border: 1px solid transparent; background: transparent;
  color: var(--txt); font: inherit; cursor: pointer; transition: all .15s; }
.chat-chan:hover { background: var(--card-2); }
.chat-chan.active { background: var(--card-2); border-color: var(--stroke-2); }
.cc-name { font-weight: 700; font-size: 13.5px; }
.cc-desc { grid-column: 1; font-size: 11px; color: var(--muted); }
.cc-count { grid-row: 1; font-size: 11px; color: var(--muted); font-weight: 700; }
.chat-note { margin-top: 14px; font-size: 11.5px; line-height: 1.5; color: var(--muted);
  border-top: 1px solid var(--stroke); padding-top: 12px; }
.chat-main { display: flex; flex-direction: column; min-height: 62vh; }
.chat-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  border-bottom: 1px solid var(--stroke); padding-bottom: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chat-me { font-size: 12px; }
.chat-msgs { flex: 1; overflow-y: auto; max-height: 52vh; padding-right: 6px; }
.chat-form { display: flex; gap: 10px; margin-top: 12px; }
.chat-form input { flex: 1; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--stroke-2);
  background: var(--card-2); color: var(--txt); font: inherit; font-size: 14px; }
.chat-form input:focus { outline: none; border-color: var(--brand); }
.chat-send { margin: 0; flex: none; padding: 0 22px; }
@media (max-width: 960px) {
  .chat-wrap { grid-template-columns: 1fr; }
  .chat-chans { flex-direction: row; flex-wrap: wrap; }
  .chat-chan { flex: 1 1 140px; }
}

/* ===== Точка «новые сообщения» в боковом меню ===== */
.nav-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand); margin-left: 7px; vertical-align: middle; }

/* ===== МИНИ-ЧАТ ===== */
.mini-chat { position: fixed; right: 22px; bottom: 22px; z-index: 900;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.mini-fab { position: relative; width: 58px; height: 58px; border-radius: 50%; border: none;
  cursor: pointer; color: #fff; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--purple-brand), var(--brand));
  box-shadow: 0 10px 26px rgba(147, 51, 234, 0.45); transition: transform .18s, box-shadow .18s; }
.mini-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px rgba(147, 51, 234, 0.6); }
.mini-fab:active { transform: scale(0.97); }
.mini-fab.open .mini-fab-ic { transform: rotate(-8deg); }
.mini-badge { position: absolute; top: -3px; right: -3px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid var(--bg); }
.mini-panel { width: 376px; max-width: calc(100vw - 32px); height: 440px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden;
  background: var(--panel); border: 1px solid var(--stroke-2); box-shadow: var(--shadow);
  backdrop-filter: blur(16px); animation: miniIn .18s ease-out; }
@keyframes miniIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.mini-head { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(147,51,234,0.25), rgba(236,27,46,0.15)); }
.mini-title { font-weight: 800; font-size: 15px; }
.mini-sub { font-size: 11.5px; color: var(--muted); }
.mini-x { background: transparent; border: none; color: var(--muted); font-size: 15px; cursor: pointer;
  padding: 4px 6px; border-radius: 8px; }
.mini-x:hover { color: var(--txt); background: rgba(255,255,255,0.08); }
.mini-full { margin: 10px 12px 0; padding: 9px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--purple-light);
  font: inherit; font-size: 12.5px; font-weight: 700; transition: all .15s; }
.mini-full:hover { background: var(--card-hover); color: #fff; border-color: var(--brand); }
.mini-msgs { flex: 1; overflow-y: auto; padding: 12px 14px 4px; }
.mini-msgs .msg { gap: 7px; }
.mini-msgs .msg-ava, .mini-msgs .msg-ava-sp { width: 26px; height: 26px; }
.mini-msgs .msg-ava { font-size: 10.5px; }
.mini-msgs .msg-ava.ava-sys { font-size: 12px; }
.mini-msgs .msg-body { max-width: calc(100% - 34px); }
.mini-msgs .msg-bubble { font-size: 12.5px; padding: 7px 10px 5px; }
.mini-msgs .msg-author { font-size: 10.5px; }
.mini-form { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--stroke); }
.mini-form input { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--stroke-2); background: var(--card-2); color: var(--txt);
  font: inherit; font-size: 13px; }
.mini-form input:focus { outline: none; border-color: var(--brand); }
.mini-send { flex: none; width: 40px; border: none; border-radius: 10px; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--purple-brand), var(--brand)); font-size: 15px; }
@media (max-width: 720px) {
  .mini-chat { right: 14px; bottom: 14px; }
  .mini-panel { width: calc(100vw - 28px); height: 62vh; }
  .mini-fab { width: 52px; height: 52px; }
}
