* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f0f2f5;
  color: #333;
  font-size: 14px;
}

/* ===================== ЛОГИН ===================== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #e8eef5 0%, #f5f7fa 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.login-header {
  position: fixed; top: 0; left: 0; right: 0;
  background: #1a3a6b; color: white;
  padding: 12px 30px; display: flex;
  justify-content: space-between; font-size: 14px;
}
.login-card {
  background: white; padding: 40px 50px; border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  min-width: 420px; text-align: center;
}
.login-card h2 { color: #1a3a6b; margin-bottom: 10px; font-size: 22px; }
.login-card p { color: #888; margin-bottom: 25px; font-size: 13px; }

.user-list { display: flex; flex-direction: column; gap: 10px; }
.user-option {
  padding: 14px 18px; border: 2px solid #e0e6ed; border-radius: 8px;
  cursor: pointer; transition: all 0.2s; text-align: left;
  display: flex; align-items: center; gap: 12px;
}
.user-option:hover { border-color: #1a73e8; background: #f5f9ff; }
.user-option .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: #1a73e8; color: white; display: flex;
  align-items: center; justify-content: center;
  font-weight: bold; font-size: 14px; flex-shrink: 0;
}
.user-option .info { flex: 1; }
.user-option .info .name { font-weight: 600; color: #222; }
.user-option .info .role { font-size: 12px; color: #888; margin-top: 2px; }

/* ===================== ТОПБАР ===================== */
.topbar {
  background: #1a3a6b; color: white; display: flex;
  align-items: center; padding: 0 24px; height: 56px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.topbar-left { display: flex; align-items: center; gap: 20px; flex: 1; }
.logo { font-weight: 700; font-size: 15px; }
.org { font-size: 13px; opacity: 0.85; }
.topbar-nav { display: flex; gap: 4px; flex: 2; justify-content: center; }
.topbar-nav a {
  color: white; text-decoration: none;
  padding: 8px 16px; border-radius: 4px;
  font-size: 14px; cursor: pointer;
}
.topbar-nav a:hover, .topbar-nav a.active { background: rgba(255,255,255,0.15); }
.topbar-right {
  display: flex; align-items: center; gap: 16px;
  flex: 1; justify-content: flex-end; font-size: 13px;
}
.user-badge {
  background: rgba(255,255,255,0.15);
  padding: 6px 12px; border-radius: 16px; cursor: pointer;
}
.logout-btn {
  background: none; border: none; color: white;
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.logout-btn:hover { background: rgba(255,255,255,0.15); }

/* ===================== КОНТЕНТ ===================== */
.content { max-width: 1500px; margin: 0 auto; padding: 30px 24px; }
h1 { font-size: 28px; font-weight: 400; color: #333; margin-bottom: 20px; }
h2 { font-size: 20px; font-weight: 500; color: #333; margin-bottom: 16px; }

/* ===================== КАРТОЧКИ, ФИЛЬТРЫ ===================== */
.card {
  background: white; border-radius: 8px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06); margin-bottom: 20px;
}
.filters {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px; background: white; padding: 16px;
  border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.filters select, .filters input {
  padding: 10px 14px; border: 1px solid #d0d7de;
  border-radius: 6px; font-size: 14px;
  background: white; min-width: 150px;
}

.btn-primary {
  background: #1a73e8; color: white; border: none;
  padding: 10px 24px; border-radius: 6px;
  font-size: 14px; cursor: pointer; font-weight: 500;
}
.btn-primary:hover { background: #1557b0; }
.btn-secondary {
  background: white; color: #1a73e8; border: 1px solid #1a73e8;
  padding: 10px 24px; border-radius: 6px;
  font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { background: #f0f7ff; }
.btn-link {
  background: none; border: none; color: #1a73e8;
  font-size: 13px; cursor: pointer; padding: 4px 0;
}
.btn-link:hover { text-decoration: underline; }
.btn-danger-link {
  background: none; border: none; color: #e74c3c;
  font-size: 13px; cursor: pointer; padding: 7px 0;
}
.btn-danger-link:hover { text-decoration: underline; }

/* ===================== ТАБЛИЦЫ ===================== */
table {
  width: 100%; border-collapse: collapse; background: white;
  border-radius: 8px; overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
th {
  background: #f6f8fa; padding: 10px 8px; text-align: left;
  font-weight: 600; font-size: 12px; color: #555;
  border-bottom: 1px solid #e8ecf0;
}
td {
  padding: 8px; border-bottom: 1px solid #f0f2f5;
  font-size: 14px; vertical-align: middle;
}
tr:hover td { background: #f8fafd; }

/* Журнал — таблица с датами */
.journal-table th.date-col {
  text-align: center; font-size: 11px; min-width: 60px;
  padding: 6px 4px;
}
.journal-table th.date-col .day {
  font-weight: 700; font-size: 14px; color: #1a3a6b;
  display: block;
}
.journal-table th.date-col .month {
  font-weight: 400; font-size: 10px; color: #888;
}
.journal-table td.grade-td { text-align: center; }
.journal-table td.summary { font-weight: 600; color: #1a3a6b; text-align: center; }

/* ===================== РАСПИСАНИЕ, ОБЪЯВЛЕНИЯ, ГЛАВНАЯ ===================== */
.schedule-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
.schedule-day {
  background: white; border-radius: 8px; padding: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.schedule-day h4 {
  font-size: 13px; color: #888; margin-bottom: 10px;
  text-align: center; padding-bottom: 8px; border-bottom: 1px solid #eee;
}
.lesson-card {
  padding: 8px; margin-bottom: 8px; border-radius: 6px;
  background: #f8fafd; border-left: 3px solid #1a73e8; font-size: 12px;
}
.lesson-card .subject { font-weight: 600; color: #1a3a6b; margin-bottom: 4px; }
.lesson-card .room { color: #888; }
.lesson-card .time { color: #1a73e8; font-size: 11px; margin-top: 4px; }

.announcement {
  padding: 16px; border-radius: 8px; margin-bottom: 12px;
  border-left: 4px solid #1a73e8; background: #f8fafd;
}
.announcement.alt { background: #fdf2f2; border-left-color: #e74c3c; }
.announcement.alt2 { background: #f0f9f4; border-left-color: #27ae60; }
.announcement .title { font-weight: 600; color: #1a3a6b; margin-bottom: 6px; }
.announcement .text { color: #666; font-size: 13px; }
.announcement .date { color: #aaa; font-size: 11px; margin-top: 6px; }

.hero {
  background: linear-gradient(135deg, #1a3a6b 0%, #2a5298 100%);
  color: white; padding: 30px; border-radius: 8px;
  margin-bottom: 24px; display: flex;
  justify-content: space-between; align-items: center;
}
.hero .time-big { font-size: 48px; font-weight: 300; }
.hero .next-lesson { text-align: right; }
.hero .next-lesson .label { font-size: 12px; opacity: 0.8; }
.hero .next-lesson .value { font-size: 20px; font-weight: 500; }

/* ===================== ЦВЕТА ОЦЕНОК ===================== */
.grade-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 10px;
  border-radius: 6px; font-weight: 600; font-size: 14px;
  color: white; user-select: none;
}
.grade-0 { background: #9aa0a6; }
.grade-1 { background: #e74c3c; }
.grade-2 { background: #e74c3c; }
.grade-3 { background: #f39c12; }
.grade-4 { background: #7ed957; }
.grade-5 { background: #1e8449; }
.grade-empty {
  background: #f0f2f5; border: 1px dashed #cfd8e3;
  color: #b0b8c1; font-weight: 400;
}
.grade-double {
  display: inline-flex; align-items: center; gap: 2px;
}
.grade-double .slash { color: #999; font-weight: 400; }

/* Ячейка в таблице журнала */
.grade-cell {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 40px; min-height: 36px; padding: 2px 6px;
  border-radius: 6px; cursor: pointer;
  background: #f8fafd; border: 1px dashed #cfd8e3;
  transition: background 0.15s;
}
.grade-cell:hover { background: #eef4fd; border-color: #1a73e8; }

/* Присутствие (в уроке) */
.attendance-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 6px;
  border: 1px solid #d0d7de; background: white;
  cursor: pointer; font-weight: 600; font-size: 12px;
  color: #555; margin-right: 2px;
  transition: all 0.15s;
}
.attendance-btn:hover { border-color: #1a73e8; }
.attendance-btn.active {
  color: white; border-color: transparent;
}
.attendance-btn.active[data-status="Б"] { background: #1a73e8; }
.attendance-btn.active[data-status="Н"] { background: #e74c3c; }
.attendance-btn.active[data-status="У"] { background: #f39c12; }

/* ===================== МАЛЕНЬКИЙ ПОПАП ОЦЕНКИ ===================== */
.grade-popup {
  position: fixed; z-index: 1000; width: 300px;
  background: white; border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  padding: 14px; font-size: 13px;
}
.grade-popup-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid #eef1f5;
}
.grade-popup-title { font-weight: 600; color: #1a3a6b; font-size: 14px; }
.grade-popup-close {
  background: none; border: none; font-size: 20px;
  color: #999; cursor: pointer; line-height: 1; padding: 0 4px;
}
.grade-popup-close:hover { color: #333; }
.grade-popup-row { margin-bottom: 10px; }
.grade-popup-checkbox {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: #444; cursor: pointer;
}
.grade-popup-comment {
  width: 100%; padding: 6px 10px;
  border: 1px solid #d0d7de; border-radius: 6px; font-size: 12px;
}
.grade-popup-label {
  display: block; font-size: 11px; color: #888; margin-bottom: 6px;
}
.grade-popup-select {
  width: 100%; padding: 8px 10px;
  border: 1px solid #d0d7de; border-radius: 6px;
  font-size: 13px; background: white;
}
.grade-options { display: flex; gap: 6px; flex-wrap: wrap; }
.grade-option {
  width: 36px; height: 36px; border-radius: 6px;
  border: 2px solid transparent; cursor: pointer;
  font-weight: 700; font-size: 15px; color: white;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, box-shadow 0.1s;
}
.grade-option:hover { transform: scale(1.08); }
.grade-option.selected {
  border-color: #1a3a6b;
  box-shadow: 0 0 0 2px rgba(26,58,107,0.25);
}
.grade-option[data-value="0"] { background: #9aa0a6; }
.grade-option[data-value="1"] { background: #e74c3c; }
.grade-option[data-value="2"] { background: #e74c3c; }
.grade-option[data-value="3"] { background: #f39c12; }
.grade-option[data-value="4"] { background: #7ed957; }
.grade-option[data-value="5"] { background: #1e8449; }
.grade-popup-actions {
  display: flex; gap: 8px; align-items: center;
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid #eef1f5;
}
.grade-popup-actions .btn-primary,
.grade-popup-actions .btn-secondary {
  padding: 7px 14px; font-size: 13px;
}
.grade-popup-open-lesson {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid #eef1f5; text-align: right;
}

/* ===================== СТРАНИЦА УРОКА ===================== */
.lesson-page {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
}
.lesson-sidebar {
  background: white; border-radius: 8px; padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  height: fit-content;
}
.lesson-sidebar a {
  display: block; padding: 10px 12px; border-radius: 6px;
  color: #1a73e8; text-decoration: none;
  cursor: pointer; font-size: 14px;
  margin-bottom: 4px;
}
.lesson-sidebar a:hover { background: #f0f7ff; }
.lesson-sidebar a.active { background: #e8f0fe; font-weight: 600; }
.lesson-sidebar .back-link {
  color: #666; font-size: 13px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}

.lesson-main {
  background: white; border-radius: 8px; padding: 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.lesson-main h1 {
  font-size: 22px; font-weight: 400; margin-bottom: 20px;
  padding-bottom: 12px; border-bottom: 1px solid #eef1f5;
}
.lesson-section { margin-bottom: 24px; }
.lesson-section h3 {
  font-size: 15px; font-weight: 600; color: #1a3a6b;
  margin-bottom: 10px;
}
.lesson-section p { font-size: 14px; color: #444; margin-bottom: 6px; }

.lesson-grade-header {
  display: flex; justify-content: space-between;
  align-items: center; margin-bottom: 12px;
  flex-wrap: wrap; gap: 12px;
}
.lesson-grade-header h3 { margin: 0; }

.lesson-worktype-select {
  padding: 8px 12px; border: 1px solid #d0d7de;
  border-radius: 6px; font-size: 13px;
  background: white; min-width: 240px;
}