:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2434;
  --muted: #7a8699;
  --accent: #c0392b;
  --nav-height: 65px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: calc(var(--nav-height) + 10px);
}

header {
  background: var(--card);
  padding: 15px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { font-size: 20px; }
.user-info { font-size: 13px; color: var(--muted); }

main { padding: 20px; }

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 25px;
}

.stat-card {
  background: var(--card);
  padding: 15px 10px;
  border-radius: 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

h2 { font-size: 16px; margin-bottom: 12px; color: var(--muted); }

.actions { display: flex; flex-direction: column; gap: 10px; }

.action-btn {
  background: var(--card);
  border: none;
  padding: 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s;
}

.action-btn:active { background: #eee; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--card);
  display: flex;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  z-index: 20;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  gap: 4px;
}

.nav-item.active { color: var(--accent); font-weight: 600; }

/* =========================================
   СТИЛИ ДЛЯ УЧЕНИКОВ
   ========================================= */

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

.students-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.student-card {
  background: var(--card);
  padding: 15px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.student-info h3 {
  font-size: 16px;
  margin-bottom: 4px;
}

.student-info p {
  font-size: 13px;
  color: var(--muted);
}

.btn-delete {
  background: #ffeaea;
  color: #d32f2f;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

/* =========================================
   МОДАЛКА
   ========================================= */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal-content {
  background: var(--card);
  padding: 20px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
}

.modal-content h3 { margin-bottom: 15px; }

.modal-input {
  width: 100%;
  padding: 12px;
  margin-bottom: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.btn-cancel, .btn-save {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-cancel { background: #eee; color: #333; }
.btn-save { background: var(--accent); color: white; }

/* АДМИН-ПАНЕЛЬ */
.admin-tabs { display: flex; gap: 5px; margin-bottom: 15px; background: #eee; padding: 5px; border-radius: 10px; }
.admin-tab { flex: 1; padding: 10px; border: none; background: transparent; border-radius: 8px; font-weight: 600; color: var(--muted); cursor: pointer; }
.admin-tab.active { background: var(--card); color: var(--accent); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.admin-section { background: var(--card); padding: 15px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.admin-item { background: #f9f9f9; padding: 12px; border-radius: 8px; margin-bottom: 8px; border-left: 3px solid var(--accent); }
.days-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.days-grid label { background: #f0f0f0; padding: 8px; border-radius: 6px; text-align: center; font-size: 14px; cursor: pointer; }

/* СЕТКА КАЛЕНДАРЯ */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-width: 400px; /* Ограничиваем ширину, чтобы не было гигантским */
  margin: 0 auto;   /* Центрируем */
}

.cal-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: var(--muted);
  padding-bottom: 5px;
}

.cal-cell {
  background: var(--card);
  border-radius: 6px;
  aspect-ratio: 1; 
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  position: relative;
  font-size: 13px;
  min-height: 36px; /* Уменьшили высоту ячейки */
}

.cal-cell.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.cal-cell:not(.empty):active {
  background: #eee;
}

/* Сегодняшний день */
.cal-cell.today {
  background: #fdf0ef;
  border: 2px solid var(--accent);
}
.cal-cell.today .cal-date {
  font-weight: 800;
  color: var(--accent);
}

.cal-cell.has-lesson {
  border: 1px solid #ffb3b3;
}

.cal-dot {
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
  position: absolute;
  bottom: 3px;
}

/* Кнопки отметок посещения */
.attendance-buttons {
  display: flex;
  gap: 5px;
  width: 100%;
}

.att-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f9f9f9;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s;
}

/* Пришел - зеленый */
.att-btn.present.active-status {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

/* Болеет - желтый */
.att-btn.sick.active-status {
  background: #fff3cd;
  border-color: #ffc107;
  color: #856404;
}

/* Отсутствует - КРАСНЫЙ */
.att-btn.absent.active-status {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

/* Вкладки в карточке ученика */
.profile-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
  overflow-x: auto;
}
.profile-tab {
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  border-radius: 6px;
}
.profile-tab.active {
  background: var(--card);
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.profile-content {
  min-height: 200px;
}

/* Красный/зеленый баланс */
.balance-plus { color: #28a745; }
.balance-minus { color: #dc3545; }

.balance-plus { color: #28a745; }
.balance-minus { color: #dc3545; }

.profile-tabs {
  display: flex; gap: 5px; margin-bottom: 15px; border-bottom: 1px solid var(--line); padding-bottom: 5px; overflow-x: auto;
}
.profile-tab {
  background: transparent; border: none; padding: 8px 12px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; border-radius: 6px;
}
.profile-tab.active { background: var(--card); color: var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.profile-content { min-height: 200px; }