*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f5f5f5;
  color: #333;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex-wrap: wrap;
}

header h1 {
  flex: 1;
  text-align: center;
  font-size: 1.4rem;
  text-transform: capitalize;
}

header button {
  padding: 0.4rem 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
}

header button:hover {
  background: #f0f0f0;
}

#edit-toggle {
  margin-left: auto;
}

#filter-select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.95rem;
  background: #fff;
  cursor: pointer;
}


#edit-toggle.active {
  background: #e8f4e8;
  border-color: #5a9c5a;
  color: #2d6a2d;
}

header.edit-mode {
  background: #fff8e1;
  border-bottom-color: #f0a500;
}

#edit-banner {
  background: #f0a500;
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

#view-filters {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #ddd;
}

#view-filters[hidden] { display: none; }

#view-filters select {
  padding: 0.35rem 0.6rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
  background: #fff;
  cursor: pointer;
}

#reset-filters,
#refresh-view {
  padding: 0.35rem 0.7rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
}

#reset-filters:hover,
#refresh-view:hover {
  background: #f0f0f0;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  padding: 4px;
  max-width: 1100px;
  margin: 0 auto;
}

#calendar-header {
  padding-top: 0.8rem;
}

#calendar.single-day {
  grid-template-columns: 1fr;
  max-width: 320px;
}

.day-header {
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: #666;
  padding: 0.3rem 0;
}

.day-cell {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  min-height: 80px;
}

.day-cell.empty-cell {
  background: transparent;
  border: none;
}

.day-cell.weekend {
  background: #f0ede8;
}

.day-cell.today {
  border-color: #4a90d9;
  border-width: 2px;
}

.day-number {
  font-size: 0.8rem;
  font-weight: 600;
  color: #666;
  padding: 4px 6px 2px;
  text-align: right;
}

.holiday .day-number {
  color: #b36b00;
}

.holiday-label {
  position: relative;
  display: inline-block;
  cursor: default;
  user-select: none;
}

.holiday-label::after {
  content: attr(data-holiday);
  position: absolute;
  bottom: calc(100% + 5px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

.holiday-label::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: #333;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}

.holiday-label:hover::after,
.holiday-label:hover::before {
  opacity: 1;
}

.slot {
  padding: 3px 6px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 4px;
  border-top: 1px solid #f0f0f0;
}

.slot-label {
  color: #999;
  font-size: 0.7rem;
  min-width: 2rem;
}

.slot-name {
  font-weight: 500;
  flex: 1;
}

.slot.yann .slot-name {
  color: #1a6ab5;
}

.slot.bruno .slot-name {
  color: #c06010;
}

.slot.empty {
  background: #fff0f0;
}

.slot.empty .slot-name {
  color: #e05050;
}

.slot.filtered-out {
  opacity: 0.15;
}

.edit-mode .day-cell:not(.empty-cell):not(.locked-day) .slot {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.1s;
}

.edit-mode .day-cell:not(.empty-cell):not(.locked-day) .slot:hover {
  background: #f8f8f8;
}

.edit-mode .slot.selected {
  background: #e8f4ff;
  outline: 2px solid #4a90d9;
  outline-offset: -2px;
}

.locked-day .day-number {
  color: #bbb;
}

.edit-mode .locked-day .day-number::after {
  content: ' \1F512';
  font-size: 0.6rem;
}

.locked-day .slot {
  opacity: 0.55;
}

#action-bar {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 2px solid #4a90d9;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

#action-bar[hidden] { display: none; }

#selection-count {
  color: #555;
  font-size: 0.9rem;
  flex: 1;
}

.action-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-buttons button {
  padding: 0.35rem 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

#apply-yann { background: #e8f0fc; border-color: #4a90d9; color: #1a6ab5; font-weight: 600; }
#apply-bruno { background: #fef0e0; border-color: #d08040; color: #c06010; font-weight: 600; }
#apply-clear { background: #f5f5f5; }

dialog {
  border: none;
  border-radius: 10px;
  padding: 2rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  min-width: 280px;
}

dialog::backdrop {
  background: rgba(0,0,0,0.4);
}

dialog h2 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

dialog input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  margin-bottom: 1rem;
}

.dialog-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.dialog-buttons button {
  padding: 0.4rem 1rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

#password-submit {
  background: #4a90d9;
  color: #fff;
  border-color: #4a90d9;
}

.error {
  color: #c0392b;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

@media (max-width: 600px) {
  .day-cell {
    min-height: 60px;
  }

  .slot-label {
    display: none;
  }

  .day-number {
    font-size: 0.7rem;
  }

  .slot-name {
    font-size: 0.7rem;
  }
}
