:root {
  --bg: #eff0f8;
  --card-bg: #ffffff;
  --border: #e1e1ec;
  --text-dark: #40414d;
  --text-mid: #6a6b7a;
  --text-light: #808191;
  --blue: #1062a3;
  --blue-dark: #004571;
  --pink: #ff7f96;
  --pink-bg: #fff1f3;
  --amber: #f6b382;
  --amber-bg: #fff6ec;
  --green: #25cf9c;
  --green-bg: #e7faf3;
  /* Warm "sepia" tint that marks a cell as votable, so it stands out from
     the plain white read-only schedule cells at a glance. */
  --sepia-bg: #fbf1e1;
  --sepia-border: #e8cfa1;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-dark);
  font-family: "Exo 2", sans-serif;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.topbar {
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.brand-badge {
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 8px;
}

.brand-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-dark);
}

.subtitle {
  margin: 0 0 10px;
  color: var(--text-mid);
  font-size: 14px;
  max-width: 640px;
  line-height: 1.5;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 0;
  padding: 0;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-mid);
}

.legend-swatch {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid var(--border);
  display: inline-block;
}

.legend-swatch-plain {
  background: var(--card-bg);
}

.legend-swatch-vote {
  background: var(--sepia-bg);
  border-color: var(--sepia-border);
}

.legend-swatch-voted {
  background: var(--green-bg);
  border-color: var(--green);
}

/* Day tabs: hidden on desktop, shown as a sticky bar on mobile */
.day-tabs {
  display: none;
}

.day-tab {
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-mid);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.day-tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

/* Desktop: a real grid/table — a time column on the left, one column per
   day, pairs aligned in rows across every day, like a spreadsheet. */
.week-grid {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.grid-day-header {
  grid-row: 1;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dark);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.grid-time-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--blue);
  border-radius: 10px;
  min-height: 96px;
}

/* Mobile day-by-day columns (hidden on desktop, shown below 860px) */
.week {
  display: none;
}

.day-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.day-heading {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-dark);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.cell {
  min-height: 96px;
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.cell-blank {
  background: transparent;
}

.cell-occupied {
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.slot-card {
  background: var(--sepia-bg);
  border: 1px solid var(--sepia-border);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}

.slot-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(232, 207, 161, 0.45);
  border-color: var(--amber);
}

.slot-card.voted {
  border-color: var(--green);
  background: var(--green-bg);
}

.type-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 8px;
  white-space: nowrap;
}

.type-badge[data-type="Практика"] {
  color: #b3184a;
  background: var(--pink-bg);
}

.type-badge[data-type="Лекція"] {
  color: var(--blue-dark);
  background: #eaf3fb;
}

.subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.35;
}

.teacher {
  font-size: 12px;
  color: var(--text-mid);
}

.group-block {
  padding-top: 6px;
  border-top: 1px dashed var(--border);
}

.group-block:first-child {
  padding-top: 0;
  border-top: none;
}

.group-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 2px;
}

.slot-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.slot-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.list-icon-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(16, 98, 163, 0.12);
  color: var(--blue-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.list-icon-btn:hover {
  background: rgba(16, 98, 163, 0.22);
}

.pair-label {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-dark);
}

.pair-time {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  padding: 3px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

.warn-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #92600f;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  padding: 3px 8px;
  border-radius: 8px;
  width: fit-content;
}

.vote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.vote-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-dark);
}

.vote-count-label {
  font-size: 11px;
  color: var(--text-light);
  font-weight: 500;
}

.vote-hint {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
}

.slot-card.voted .vote-count {
  color: var(--green);
}

.slot-card.voted .vote-hint {
  color: var(--green);
}

.slot-card.voted .vote-hint::before {
  content: "✓ ";
}

/* Modals: centered on the page, page dims behind them */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 21, 24, 0.5);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

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

.modal {
  position: relative;
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 24px 60px rgba(20, 21, 24, 0.35);
}

.modal h3 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text-dark);
  padding-right: 10px;
}

.name-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 16px;
}

.name-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(16, 98, 163, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn-cancel {
  background: var(--bg);
  color: var(--text-mid);
}

.btn-cancel:hover {
  background: var(--border);
}

.btn-confirm {
  background: var(--blue);
  color: #fff;
}

.btn-confirm:hover {
  background: var(--blue-dark);
}

.modal-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #e5484d;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, transform 0.12s ease;
}

.modal-close:hover {
  background: #c53030;
  transform: scale(1.08);
}

.names-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
}

.names-list li {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dark);
}

.names-list li:last-child {
  border-bottom: none;
}

.names-empty {
  color: var(--text-light);
  font-size: 13px;
  padding: 4px 0;
}

/* Mobile: swipeable day-by-day view instead of the desktop grid/table */
@media (max-width: 860px) {
  .week-grid {
    display: none;
  }

  .day-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    margin-bottom: 4px;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 5;
  }

  .week {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 0;
    margin: 0 -20px;
  }

  /* Each column is exactly one viewport wide with its own matching left
     and right gutter, so one swipe = exactly one day with no sliver of
     the next day showing and no content glued to the screen edge. */
  .day-column {
    flex: 0 0 100%;
    scroll-snap-align: start;
    padding: 0 20px;
  }
}
