:root {
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --ink: #1F2937;
  --muted: #6B7280;
  --line: #E5E7EB;
  --accent: #3B82F6;
  --danger: #EF4444;
  --danger-soft: #FEE2E2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
}

.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.who label { color: var(--muted); font-size: 14px; }

.who select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  font-weight: 600;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

/* Сводка */
.summary {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  min-width: 200px;
}

.summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
}

.summary-value {
  margin-top: 4px;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.summary-card.alert { border-left: 4px solid var(--danger); }
.summary-card.alert .summary-value { font-size: 15px; color: #B91C1C; }

/* Наставники */
.mentors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.mentor-card {
  background: var(--card);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border-top: 4px solid transparent;
}

.mentor-card.is-me { box-shadow: 0 0 0 2px var(--accent), 0 1px 3px rgba(0,0,0,.08); }

.mentor-name {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mentor-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mentor-stats {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.colors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  margin-top: 10px;
}

.color-btn {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-btn.is-active { border-color: var(--ink); }
.color-btn:disabled { cursor: default; opacity: .45; }

/* Панель с инструкцией */
.main-content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.guide {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.guide-inner {
  background: var(--card);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  font-size: 14px;
  line-height: 1.5;
}

.guide h2 {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
}

.guide h3 {
  margin: 20px 0 8px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.guide p { margin: 0 0 10px; }

.guide-note {
  background: #EFF6FF;
  color: #1E40AF;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}

.steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.steps li::marker { font-weight: 700; color: var(--accent); }

.marks, .rules {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.marks li { display: flex; gap: 10px; align-items: flex-start; }

.rules {
  padding-left: 18px;
  list-style: disc;
  gap: 6px;
}

.rules li::marker { color: var(--muted); }

.mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.swatch-working { background: #fff; color: #374151; }
.swatch-duty { background: linear-gradient(135deg, #3B82F6, #8B5CF6); border-color: transparent; color: #fff; }
.swatch-dayoff { background: #E5E7EB; color: var(--muted); }

/* Недели */
.weeks { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.week {
  min-width: 0;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow: hidden;
}

.week.is-current { box-shadow: 0 0 0 2px var(--accent), 0 1px 3px rgba(0,0,0,.08); }

.week-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.week-number { font-weight: 700; font-size: 16px; }
.week-title { color: var(--muted); font-size: 14px; }
.week-dates { margin-left: auto; color: var(--muted); font-size: 13px; }
.week-badge {
  background: #EFF6FF;
  color: #1D4ED8;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
}

.week-badge-warn { background: var(--danger-soft); color: #B91C1C; }

.week-body { overflow-x: auto; }

table.grid {
  border-collapse: collapse;
  width: 100%;
  min-width: 640px;
}

.grid th, .grid td {
  border-bottom: 1px solid var(--line);
  padding: 0;
}

.grid thead th {
  padding: 10px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.grid thead th.day-head { text-align: center; }
.grid thead th.day-head.is-today { color: var(--accent); }
.grid thead th .day-date { display: block; font-size: 11px; font-weight: 500; letter-spacing: 0; text-transform: none; }

.grid th.mentor-head {
  text-align: left;
  padding-left: 18px;
  min-width: 130px;
  position: sticky;
  left: 0;
  background: var(--card);
  z-index: 1;
}

.grid tbody th.mentor-head {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}

.mentor-head-inner { display: flex; align-items: center; gap: 8px; padding: 8px 0; }

.cell-wrap { padding: 4px; position: relative; }

.cell {
  width: 100%;
  min-width: 56px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: transform .08s ease;
}

.cell:hover:not(:disabled) { transform: translateY(-1px); }
.cell:disabled { cursor: default; opacity: .4; }
.cell.is-dayoff { background: #E5E7EB; color: var(--muted); }
.cell.is-error { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-soft); }
.cell.is-today { outline: 2px dashed rgba(59,130,246,.5); outline-offset: -3px; }

.row-error {
  font-size: 12px;
  color: #B91C1C;
  padding: 0 4px 6px;
}

.day-alert {
  font-size: 11px;
  color: #B91C1C;
  text-align: center;
  padding: 0 4px 6px;
}

/* Меню выбора статуса */
.menu {
  position: absolute;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  padding: 6px;
  min-width: 170px;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--ink);
}

.menu button:hover { background: #F3F4F6; }
.menu button.is-active { font-weight: 700; }

.menu .mini {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.page-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #1F2937;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.error { background: #B91C1C; }

@media (max-width: 1100px) {
  .main-content { grid-template-columns: minmax(0, 1fr); }
  .guide { position: static; order: -1; max-height: none; overflow: visible; }
}

@media (max-width: 640px) {
  h1 { font-size: 21px; }
  .page { padding: 16px 12px 40px; }
  .week-dates { margin-left: 0; width: 100%; }
}
