.shift-matrix-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
  padding: 16px 20px 24px;
  overflow: hidden;
}

.shift-matrix-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.shift-matrix-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: #1f2937;
}

.shift-matrix-header__left {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.shift-matrix-display-filter {
  margin: 0;
  padding: 0;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.shift-matrix-display-filter-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shift-matrix-display-filter__option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #374151;
}

.shift-matrix-display-filter__hint {
  margin: 0;
  font-size: 11px;
  color: #6b7280;
}

.shift-matrix-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shift-matrix-nav__link {
  text-decoration: none;
  color: #2563eb;
  font-weight: 600;
}

.shift-matrix-nav__link:hover {
  text-decoration: underline;
}

.shift-matrix-nav__current {
  font-weight: 700;
  color: #111827;
}

.shift-matrix-table-wrapper {
  flex: 1;
  overflow: auto;
  background: #ffffff;
}

.shift-matrix-table {
  border-collapse: separate;
  border-spacing: 0;
  /*
   * 列幅は全て固定なので、Ruby側で日数分の表幅を確定させる。
   * autoのままだと列幅の決定時に全セルを走査する。
   */
  table-layout: fixed;
  width: var(--shift-matrix-table-width);
  min-width: 100%;
  font-size: 13px;
}

.shift-matrix-table__head,
.shift-matrix-summary-label,
.shift-matrix-summary-cell,
.shift-matrix-table__staff,
.shift-matrix-cell {
  border: 0;
  border-right: 1px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

.shift-matrix-table__head--staff,
.shift-matrix-summary-label,
.shift-matrix-table__staff {
  border-left: 1px solid #e5e7eb;
}

.shift-matrix-table__head {
  position: sticky;
  top: 0;
  border-bottom: 0;
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  z-index: 2;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
  width: 45px;
  min-width: 45px;
  max-width: 45px;
}

.shift-matrix-table__head--today {
  background: #eef7ff;
}

.shift-matrix-table__head--staff {
  left: 0;
  z-index: 3;
  min-width: 140px;
  width: 140px;
  max-width: 140px;
}

.shift-matrix-summary-label,
.shift-matrix-summary-cell {
  border-top: 1px solid #e5e7eb;
  border-bottom: 0;
  background: #f9fafb;
  padding: 4px;
  text-align: center;
  white-space: nowrap;
  background-clip: border-box;
}

.shift-matrix-summary-row:last-child .shift-matrix-summary-label,
.shift-matrix-summary-row:last-child .shift-matrix-summary-cell {
  border-bottom: 3px solid #6b7280;
}

.shift-matrix-summary-label {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 140px;
  width: 140px;
  max-width: 140px;
  color: #374151;
}

.shift-matrix-summary-cell {
  min-width: 45px;
  width: 45px;
  max-width: 45px;
  color: #111827;
}

.shift-matrix-summary-cell--zero {
  color: #9ca3af;
}

.shift-matrix-summary-cell--today {
  background: #eef7ff;
}

.shift-matrix-summary-row--total .shift-matrix-summary-label,
.shift-matrix-summary-row--total .shift-matrix-summary-cell {
  background: #f3f4f6;
  font-weight: 700;
}

.shift-matrix-summary-row--total .shift-matrix-summary-cell--today {
  background: #e5f1fb;
}

.shift-matrix-date {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shift-matrix-date__day {
  font-weight: 700;
}

.shift-matrix-date__wday {
  font-size: 11px;
  color: #6b7280;
}

.shift-matrix-date__wday--sunday {
  color: #dc2626;
}

.shift-matrix-date__wday--saturday {
  color: #2563eb;
}

.shift-matrix-table__staff {
  position: sticky;
  left: 0;
  background: #ffffff;
  z-index: 1;
  padding: 10px;
  min-width: 140px;
  width: 140px;
  max-width: 140px;
  font-weight: 600;
  color: #1f2937;
}

.shift-matrix-table__staff--selectable {
  cursor: pointer;
  user-select: none;
}

.shift-matrix-table__staff--selectable:focus-visible {
  outline: 2px solid #ddd4ff;
  outline-offset: -2px;
}

.shift-matrix-table__staff-name {
  display: inline-block;
  width: 100%;
}

.shift-matrix-table__staff-link {
  color: inherit;
  text-decoration: none;
  display: inline-block;
  width: 100%;
}

.shift-matrix-table__staff-link:hover {
  text-decoration: underline;
}

.shift-matrix-table__row--highlighted .shift-matrix-table__staff,
.shift-matrix-table__row--highlighted .shift-matrix-cell {
  background: #f7f3ff;
}

.shift-matrix-table__row--highlighted .shift-matrix-cell:hover,
.shift-matrix-table__row--highlighted .shift-matrix-cell--today:hover {
  background: #f2ecff;
}

.shift-matrix-table__staff--highlighted {
  background: #f7f3ff !important;
}

.shift-matrix-cell--row-highlighted {
  background: #f7f3ff !important;
}

.shift-matrix-cell--row-highlighted:hover,
.shift-matrix-cell--row-highlighted.shift-matrix-cell--today:hover {
  background: #f2ecff !important;
}

/* 今日列は行ハイライトより優先する */
.shift-matrix-cell--today.shift-matrix-cell--row-highlighted {
  background: #eef7ff !important;
}

.shift-matrix-cell--today.shift-matrix-cell--row-highlighted:hover {
  background: #e6f2ff !important;
}

.shift-matrix-cell {
  min-width: 45px;
  width: 45px;
  max-width: 45px;
  padding: 3px;
  cursor: pointer;
  vertical-align: top;
  background: #ffffff;
  text-align: center;
  transition: background 0.15s ease;
}

.shift-matrix-cell--today {
  background: #eef7ff;
}

.shift-matrix-cell:hover {
  background: #f3f4f6;
}

.shift-matrix-cell--today:hover {
  background: #e6f2ff;
}

.shift-matrix-cell__times {
  font-weight: 600;
  color: #111827;
  min-height: 18px;
  text-align: center;
  white-space: pre-line;
  padding-top: 0;
  padding-bottom: 0;
}

.shift-matrix-cell__memo {
  margin-top: 3px;
  font-size: 11px;
  color: #6b7280;
  white-space: pre-wrap;
  text-align: center;
  padding-top: 0;
  padding-bottom: 0;
}

@media (max-width: 768px) {
  .shift-matrix-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .shift-matrix-header__left {
    width: 100%;
    justify-content: flex-start;
    gap: 10px;
  }

  .shift-matrix-table {
    width: var(--shift-matrix-table-width-mobile);
  }

  .shift-matrix-table__head--staff,
  .shift-matrix-table__staff,
  .shift-matrix-summary-label {
    min-width: 140px;
    width: 140px;
    max-width: 140px;
  }

  .shift-matrix-cell,
  .shift-matrix-summary-cell {
    min-width: 120px;
  }
}
