* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  margin: 0;
  padding: 1rem;
  background: #f5f5f5;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem 0;
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
}

.week-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.week-input-wrap label {
  font-size: 0.9rem;
  color: #444;
}

#week-input {
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  min-width: 180px;
}

.week-label {
  font-size: 0.9rem;
  color: #555;
}

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

#calendar-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

#calendar-table th,
#calendar-table td {
  border: 1px solid #e0e0e0;
  padding: 0.15rem 0.2rem;
  text-align: center;
}

#calendar-table thead th {
  background: #37474f;
  color: #fff;
  font-weight: 600;
}

.time-col {
  min-width: 18px;
  width: 18px;
  font-size: 0.65rem;
  padding: 0.15rem 0.1rem;
}

.day-group {
  font-size: 0.75rem;
  padding: 0.25rem 0;
}

#calendar-table th.time-col.day-start,
#calendar-table td.cell.day-start {
  border-left: 3px solid #263238;
}

#calendar-table thead th.day-group + th.day-group {
  border-left: 3px solid #263238;
}

.person-col {
  min-width: 48px;
  width: 48px;
  text-align: left !important;
  position: sticky;
  left: 0;
  background: #37474f;
  z-index: 1;
}

.person-cell {
  text-align: left !important;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.cell {
  min-width: 18px;
  width: 18px;
  height: 28px;
  cursor: pointer;
  transition: background-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.cell:hover {
  box-shadow: inset 0 0 0 2px rgba(0,120,60,0.4);
}

.cell.selected {
  font-weight: bold;
  color: #1b5e20;
}

.table-info {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #eceff1;
  border-radius: 6px;
  font-size: 0.85rem;
  color: #37474f;
}

.table-info p {
  margin: 0.25rem 0;
}

.table-info p:first-child {
  margin-top: 0;
}

.table-info p:last-child {
  margin-bottom: 0;
}

/* ========== Mobile responsive ========== */

@media (max-width: 768px) {
  body {
    padding: 0.5rem;
  }

  .header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .week-input-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .week-input-wrap label {
    font-size: 0.85rem;
  }

  #week-input {
    min-width: 0;
    width: 100%;
  }

  .week-label {
    font-size: 0.8rem;
    word-break: break-word;
  }

  .table-wrap {
    margin: 0 -0.5rem;
    border-radius: 0;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }

  #calendar-table {
    font-size: 0.8rem;
  }

  #calendar-table th,
  #calendar-table td {
    padding: 0.25rem 0.2rem;
  }

  .person-col {
    min-width: 44px;
    width: 44px;
    font-size: 0.8rem;
  }

  .person-cell {
    font-size: 0.85rem;
  }

  .time-col {
    min-width: 18px;
    width: 18px;
    font-size: 0.6rem;
  }

  .cell {
    min-width: 18px;
    width: 18px;
    height: 32px;
    min-height: 32px;
  }

  .table-info {
    margin-top: 0.75rem;
    padding: 0.6rem 0.75rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0.4rem;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .person-col {
    min-width: 40px;
    width: 40px;
  }

  .person-cell {
    font-size: 0.8rem;
  }

  .time-col {
    min-width: 16px;
    width: 16px;
    font-size: 0.55rem;
  }

  .cell {
    min-width: 16px;
    width: 16px;
    height: 30px;
    min-height: 30px;
  }

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

  .table-info p {
    margin: 0.2rem 0;
  }

  .table-info {
    font-size: 0.75rem;
    padding: 0.5rem 0.6rem;
  }
}
